KickJava   Java API By Example, From Geeks To Geeks.

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


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.Constants;
11 import org.exoplatform.text.template.DataBindingValue;
12 import org.exoplatform.text.template.DataHandler;
13 /**
14  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
15  * @since Feb 3, 2005
16  * @version $Id$
17  */

18 public class LinkColumn extends Column {
19   private DataBindingValue beanId_ ;
20   private String JavaDoc parameters_ = "";
21   
22   public LinkColumn(String JavaDoc header, String JavaDoc value, String JavaDoc beanid) {
23     super(header, value) ;
24     beanId_ = new DataBindingValue(beanid) ;
25   }
26   
27   public LinkColumn addParameter(String JavaDoc name, String JavaDoc value) {
28     parameters_ += Constants.AMPERSAND + name + "=" + value ;
29     return this ;
30   }
31   
32   public void renderCell(XhtmlDataHandlerManager manager,
33                          ResourceBundle JavaDoc res, Writer JavaDoc w) throws IOException JavaDoc {
34     if(cssClass_ == null) {
35       w.write("<td>") ;
36     } else {
37       w.write("<td class='") ; w.write(cssClass_); w.write("'>") ;
38     }
39     DataHandler dhandler = manager.getDataHandler(dataHandlerType_);
40     String JavaDoc linkLabel = resolveValueAsString(data_, dhandler, res) ;
41     String JavaDoc id = dhandler.getValueAsString(beanId_) ;
42     String JavaDoc baseURL = manager.getBaseURL() ;
43     w.write("<a HREF='");
44     w.write(baseURL); w.write(parameters_) ;
45     w.write(Constants.AMPERSAND + "objectId="); w.write(id) ;
46     w.write("'>");
47     w.write(linkLabel);
48     w.write("</a>");
49     w.write("</td>") ;
50   }
51 }
52
Popular Tags