KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > model > Column


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.faces.core.component.model;
6
7 import java.util.ResourceBundle JavaDoc ;
8 import java.io.IOException JavaDoc;
9 import javax.faces.context.ResponseWriter;
10 import org.exoplatform.commons.utils.ExpressionUtil;
11 import org.exoplatform.faces.core.component.UIGrid;
12
13 /**
14  * Jun 30, 2004
15  * @author: Tuan Nguyen
16  * @email: tuan08@users.sourceforge.net
17  * @version: $Id: Column.java,v 1.3 2004/08/02 17:36:44 benjmestrallet Exp $
18  */

19 public class Column {
20   protected String JavaDoc header_;
21   protected String JavaDoc headerClass_;
22   protected String JavaDoc clazz_;
23   String JavaDoc fieldName_;
24
25   public Column(String JavaDoc header, String JavaDoc fieldName) {
26     header_ = header;
27     fieldName_ = fieldName;
28   }
29
30   public String JavaDoc getHeader() {
31     return header_;
32   }
33
34   public String JavaDoc getFieldName() {
35     return fieldName_;
36   }
37
38   public Column setHeaderClass(String JavaDoc clazz) {
39     headerClass_ = clazz;
40     return this;
41   }
42
43   public Column setCellClass(String JavaDoc clazz) {
44     clazz_ = clazz;
45     return this;
46   }
47
48   public void renderHeader(ResponseWriter w, ResourceBundle JavaDoc res) throws IOException JavaDoc {
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 JavaDoc res,
61                      UIGrid uiParent, DataHandler dhandler) throws IOException JavaDoc {
62     String JavaDoc 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