KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > text > template > xhtml > Cell


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.text.template.xhtml;
6
7 import java.io.IOException JavaDoc;
8 import java.io.Writer JavaDoc;
9 import java.util.ResourceBundle JavaDoc;
10 import org.exoplatform.text.template.DataBindingValue;
11 import org.exoplatform.text.template.DataHandler;
12 /**
13  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
14  * @since Feb 1, 2005
15  * @version $Id$
16  */

17 public class Cell extends Text {
18   protected String JavaDoc attributes_ ;
19   
20   public Cell(String JavaDoc value) {
21     super(value) ;
22   }
23   
24   public Cell addArribute(String JavaDoc name, String JavaDoc value) {
25     if(attributes_ == null) attributes_ = "" ;
26     attributes_ += " " + name + "='" + value +"'" ;
27     return this ;
28   }
29   
30   public void render(XhtmlDataHandlerManager manager,
31                      ResourceBundle JavaDoc res, Writer JavaDoc w) throws IOException JavaDoc {
32     w.write("<td") ;
33     if(cssClass_ != null) {
34       w.write(" class='") ;w.write(cssClass_); w.write("'") ;
35     }
36     if(cssStyle_ != null) {
37       w.write(" style='") ;w.write(cssStyle_); w.write("'") ;
38     }
39     if(attributes_ != null) {
40       w.write(attributes_) ;
41     }
42     w.write(">");
43     if(data_ != null) {
44       DataHandler dh = manager.getDataHandler(dataHandlerType_) ;
45       if(formater_ != null) {
46         formater_.format(w, dh.getValue((DataBindingValue)data_)) ;
47       } else {
48         w.write(resolveValueAsString(data_ ,dh, res)) ;
49       }
50     }
51     if(children_.length > 0) {
52       for(int i = 0 ; i < children_.length; i++) {
53         children_[i].render(manager, res, w) ;
54       }
55     }
56     w.write("</td>") ;
57   }
58   
59 }
Popular Tags