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.Constants; 11 import org.exoplatform.text.template.DataBindingValue; 12 import org.exoplatform.text.template.DataHandler; 13 18 public class LinkColumn extends Column { 19 private DataBindingValue beanId_ ; 20 private String parameters_ = ""; 21 22 public LinkColumn(String header, String value, String beanid) { 23 super(header, value) ; 24 beanId_ = new DataBindingValue(beanid) ; 25 } 26 27 public LinkColumn addParameter(String name, String value) { 28 parameters_ += Constants.AMPERSAND + name + "=" + value ; 29 return this ; 30 } 31 32 public void renderCell(XhtmlDataHandlerManager manager, 33 ResourceBundle res, Writer w) throws IOException { 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 linkLabel = resolveValueAsString(data_, dhandler, res) ; 41 String id = dhandler.getValueAsString(beanId_) ; 42 String 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 |