1 5 package org.exoplatform.text.template.xhtml; 6 7 import java.io.IOException ; 8 import java.io.Writer ; 9 import java.util.ResourceBundle ; 10 import org.exoplatform.commons.utils.ExpressionUtil; 11 import org.exoplatform.text.template.*; 12 17 public class Column extends Element { 18 protected Value header_ ; 19 protected Value data_ ; 20 21 public Column(String value) { 22 if(ExpressionUtil.isResourceBindingExpression(value)) { 23 data_ = new ResourceBindingValue(value) ; 24 } else if(ExpressionUtil.isDataBindingExpression(value)) { 25 data_ = new DataBindingValue(value) ; 26 } else { 27 data_ = new StringValue(value) ; 28 } 29 } 30 31 public Column(String header, String value) { 32 this(value) ; 33 if(ExpressionUtil.isResourceBindingExpression(header)) { 34 header_ = new ResourceBindingValue(header) ; 35 } else { 36 header_ = new StringValue(header) ; 37 } 38 } 39 40 public Value getHeader() { return header_ ; } 41 42 public Value getData() { return data_ ; } 43 44 public void renderHeader(ResourceBundle res, Writer w) throws IOException { 45 w.write("<th>") ; 46 w.write(resolveValueAsString(header_, null, res)) ; 47 w.write("</th>") ; 48 } 49 50 public void renderCell(XhtmlDataHandlerManager manager, 51 ResourceBundle res, Writer w) throws IOException { 52 if(cssClass_ == null) { 53 w.write("<td>") ; 54 } else { 55 w.write("<td class='") ; w.write(cssClass_); w.write("'>") ; 56 } 57 DataHandler dhandler = manager.getDataHandler(dataHandlerType_); 58 if(formater_ != null) { 59 formater_.format(w, dhandler.getValue((DataBindingValue)data_)) ; 60 } else { 61 w.write(resolveValueAsString(data_ ,dhandler, res)) ; 62 } 63 w.write("</td>") ; 64 } 65 66 public void render(XhtmlDataHandlerManager manager, 67 ResourceBundle res, Writer w) throws IOException { 68 throw new RuntimeException ("This method should not be called"); 69 } 70 } | Popular Tags |