KickJava   Java API By Example, From Geeks To Geeks.

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


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.commons.utils.ExpressionUtil;
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 Button extends Text {
19   private String JavaDoc parameters_ = "";
20   
21   public Button(String JavaDoc value) {
22     super(value) ;
23   }
24   
25   public Button addParameter(String JavaDoc name, String JavaDoc value) {
26     parameters_ += Constants.AMPERSAND + name + "=" + value ;
27     return this ;
28   }
29   
30   public void render(XhtmlDataHandlerManager manager,
31                      ResourceBundle JavaDoc res, Writer JavaDoc w) throws IOException JavaDoc {
32     DataHandler dh = manager.getDataHandler(dataHandlerType_) ;
33     String JavaDoc baseURL = manager.getBaseURL() ;
34     w.write("<a");
35     if (cssClass_ != null) {
36       w.write(" class='"); w.write(cssClass_); w.write("'");
37     }
38     w.write(" HREF='"); w.write(baseURL); w.write(parameters_); w.write("'>");
39     w.write(ExpressionUtil.getExpressionValue(res,resolveValueAsString(data_ ,dh, res)));
40     w.write("</a>");
41   }
42 }
43
Popular Tags