1 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 ; 16 import java.util.List ; 17 import java.util.ResourceBundle ; 18 19 24 public class ProducerNodeRenderer extends HtmlBasicRenderer { 25 26 final public static String NO_PRODUCER_ICON = "<img class='no-producer-icon' SRC='/skin/blank.gif'/>"; 27 28 public void encodeChildren(FacesContext context, UIComponent component) throws IOException { 29 UIProducerNode producerNode = (UIProducerNode) component; 30 ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()) ; 31 ResponseWriter w = context.getResponseWriter(); 32 List 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 |