KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > model > 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.faces.core.component.model;
6
7 import java.io.IOException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9 import javax.faces.context.ResponseWriter;
10 import org.exoplatform.Constants;
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: ActionColumn.java,v 1.4 2004/07/02 04:41:04 tuan08 Exp $
18  */

19 public class LinkColumn extends Column {
20   private String JavaDoc fieldId_ ;
21   protected String JavaDoc parameters_ = "";
22     
23     public LinkColumn(String JavaDoc header, String JavaDoc fieldName, String JavaDoc fieldId) {
24         super(header, fieldName) ;
25     fieldId_ = fieldId ;
26   }
27   
28     public LinkColumn addParameter(Parameter[] params) {
29       StringBuffer JavaDoc b = new StringBuffer JavaDoc() ;
30       for(int i = 0; i < params.length; i++) {
31         b.append(Constants.AMPERSAND);
32         b.append(params[i].getName()).append('=').append(params[i].getValue());
33       }
34       parameters_ = b.toString() ;
35     return this ;
36     }
37     
38   public void render(ResponseWriter w, ResourceBundle JavaDoc res,
39                      UIGrid uiParent, DataHandler dhandler) throws IOException JavaDoc {
40     if(clazz_ == null) {
41       w.write("<td>");
42     } else {
43       w.write("<td class='"); w.write(clazz_); w.write("'>");
44     }
45     String JavaDoc baseURL = uiParent.getBaseURL() ;
46     w.write("<a");
47     if (clazz_ != null) {
48       w.write(" class='"); w.write(clazz_); w.write("'");
49     }
50     w.write(" HREF='"); w.write(baseURL); w.write(parameters_) ;
51     w.write(Constants.AMPERSAND + "objectId="); w.write(dhandler.getData(fieldId_)) ;
52     w.write("'>");
53     w.write(dhandler.getData(fieldName_));
54     w.write("</a>");
55     w.write("</td>") ;
56   }
57 }
Popular Tags