1 5 package org.exoplatform.faces.core.component.model; 6 7 import java.util.ResourceBundle ; 8 import java.io.IOException ; 9 import javax.faces.context.ResponseWriter; 10 import org.exoplatform.commons.utils.ExpressionUtil; 11 import org.exoplatform.faces.core.component.UIGrid; 12 13 19 public class Column { 20 protected String header_; 21 protected String headerClass_; 22 protected String clazz_; 23 String fieldName_; 24 25 public Column(String header, String fieldName) { 26 header_ = header; 27 fieldName_ = fieldName; 28 } 29 30 public String getHeader() { 31 return header_; 32 } 33 34 public String getFieldName() { 35 return fieldName_; 36 } 37 38 public Column setHeaderClass(String clazz) { 39 headerClass_ = clazz; 40 return this; 41 } 42 43 public Column setCellClass(String clazz) { 44 clazz_ = clazz; 45 return this; 46 } 47 48 public void renderHeader(ResponseWriter w, ResourceBundle res) throws IOException { 49 if (headerClass_ == null) { 50 w.write("<th>"); 51 w.write(ExpressionUtil.getExpressionValue(res,header_)) ; 52 w.write("</th>"); 53 } else { 54 w.write("<th class='"); w.write(headerClass_); w.write("'>") ; 55 w.write(ExpressionUtil.getExpressionValue(res,header_)) ; 56 w.write("</th>"); 57 } 58 } 59 60 public void render(ResponseWriter w, ResourceBundle res, 61 UIGrid uiParent, DataHandler dhandler) throws IOException { 62 String data = dhandler.getData(fieldName_) ; 63 if (data == null) data = ""; 64 if (clazz_ == null) { 65 w.write("<td>"); w.write(data); w.write("</td>"); 66 } else { 67 w.write("<td class='"); w.write(clazz_); w.write("'>"); 68 w.write(data); 69 w.write("</td>"); 70 } 71 } 72 } | Popular Tags |