KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > renderer > html > LinkRenderer


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.renderer.html;
6
7 import java.io.IOException JavaDoc;
8 import javax.faces.context.ResponseWriter;
9 import org.exoplatform.faces.core.component.UIExoComponent;
10 import org.exoplatform.faces.core.component.model.Parameter;
11 /**
12  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
13  * @since Aug 28, 2004
14  * @version $Id: LinkRenderer.java,v 1.2 2004/10/13 03:26:54 tuan08 Exp $
15  */

16 public class LinkRenderer {
17   public void renderSelect(ResponseWriter w, UIExoComponent component,
18                            String JavaDoc text, Parameter[] params) throws IOException JavaDoc {
19     render(w, component, text, "select-link", params, null) ;
20   }
21   
22   public void render(ResponseWriter w, UIExoComponent component,
23                      String JavaDoc text, Parameter[] params) throws IOException JavaDoc {
24     render(w, component, text, "link", params, null) ;
25   }
26   
27   public void render(ResponseWriter w, UIExoComponent component,
28                      String JavaDoc text, String JavaDoc clazz, Parameter[] params) throws IOException JavaDoc {
29     render(w, component, text, clazz, params, null) ;
30   }
31   
32   public void render(ResponseWriter w, UIExoComponent component,
33                      String JavaDoc text, String JavaDoc clazz, Parameter[] params,
34                      String JavaDoc tooltip) throws IOException JavaDoc {
35     w.write("<a");
36     if(clazz != null) {
37       w.write(" class='"); w.write(clazz); w.write("'");
38     }
39     w.write(" HREF='");
40     w.write(component.getBaseURL());
41     for (int i = 0; i < params.length; i++) {
42       w.write("&amp;");
43       w.write(params[i].getName());
44       w.write('=');
45       w.write(params[i].getValue());
46     }
47     w.write("'");
48     if (tooltip == null || tooltip.length() == 0) {
49       w.write(">");
50     } else {
51       w.write(" alt='"); w.write(tooltip); w.write("'");
52       w.write(" title='"); w.write(tooltip); w.write("'>");
53     }
54     writeText(w, text) ;
55     w.write("</a>");
56   }
57   
58   protected void writeText(ResponseWriter w, String JavaDoc text) throws IOException JavaDoc {
59     w.write(text);
60   }
61 }
Popular Tags