KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > wsrp > renderer > html > ProducerNodeRenderer


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
6 package org.exoplatform.portlets.wsrp.renderer.html;
7
8
9 import javax.faces.context.FacesContext;
10 import javax.faces.context.ResponseWriter;
11 import javax.faces.component.UIComponent;
12 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer;
13 import org.exoplatform.portlets.wsrp.component.UIProducerMenu;
14 import org.exoplatform.portlets.wsrp.component.UIProducerNode;
15 import java.io.IOException JavaDoc;
16 import java.util.List JavaDoc;
17 import java.util.ResourceBundle JavaDoc;
18
19 /**
20  * Created y the eXo platform team
21  * User: Benjamin Mestrallet
22  * Date: 6 juin 2004
23  */

24 public class ProducerNodeRenderer extends HtmlBasicRenderer {
25
26   final public static String JavaDoc NO_PRODUCER_ICON = "<img class='no-producer-icon' SRC='/skin/blank.gif'/>";
27
28   public void encodeChildren(FacesContext context, UIComponent component) throws IOException JavaDoc {
29     UIProducerNode producerNode = (UIProducerNode) component;
30     ResourceBundle JavaDoc res = getApplicationResourceBundle(context.getExternalContext()) ;
31     ResponseWriter w = context.getResponseWriter();
32     List JavaDoc children = component.getChildren();
33     w.write("<table class='UIProducerNode'>");
34     w.write("<tr>");
35     if (!producerNode.hasProducer()) {
36       w.write("<td class='no-producer'>");
37       w.write(NO_PRODUCER_ICON + res.getString("UIProducerNode.label.no-producers"));
38       w.write("</td>");
39     } else {
40       for (int i = 0; i < children.size(); i++) {
41         UIComponent uiChild = (UIComponent) children.get(i);
42         if (uiChild instanceof UIProducerMenu) {
43           w.write("<td class='UIProducerMenu'>");
44         } else {
45           w.write("<td width='*'>");
46         }
47         uiChild.encodeBegin(context);
48         uiChild.encodeChildren(context);
49         uiChild.encodeEnd(context);
50         w.write("</td>");
51       }
52     }
53     w.write("</tr>");
54     w.write("</table>");
55   }
56
57 }
58
Popular Tags