1 5 package org.exoplatform.faces.core.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.List ; 9 import javax.faces.component.UIComponent; 10 import javax.faces.context.ExternalContext; 11 import javax.faces.context.FacesContext; 12 import javax.faces.context.ResponseWriter; 13 import org.exoplatform.faces.core.component.Node; 14 import org.exoplatform.faces.core.component.UINode; 15 import org.exoplatform.faces.core.component.model.Parameter; 16 17 public class NodeTabbedPaneRenderer extends NodeMenuRenderer { 18 public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 19 UINode uiNode = (UINode) component ; 20 List children = uiNode.getChildren() ; 21 if(children.size() == 0 ) return ; 22 UIComponent uiSelectTab = null ; 23 ExternalContext eContext = context.getExternalContext() ; 24 String baseURL = eContext.encodeActionURL(null) ; 25 ResponseWriter w = context.getResponseWriter() ; 26 String clazz = uiNode.getClazz() ; 27 if (clazz == null) { 28 w.write("<div>") ; 29 } else { 30 w.write("<div class='") ; w.write(clazz) ; w.write("'>") ; 31 } 32 if (children.size() > 1) { 33 Parameter tabIdParam = new Parameter("tabId" , ""); 34 Parameter[] params = {SELECT_TAB , tabIdParam} ; 35 w.write("<table class='UITabbedPane'><tr>\n") ; 36 for (int i = 0; i < children.size(); i++) { 37 UIComponent child = (UIComponent) children.get(i) ; 38 Node tab = (Node) child ; 39 tabIdParam.setValue(child.getId()) ; 40 if (child.isRendered()) { 41 uiSelectTab = child ; 42 w.write("<td class='selected-tab-left' SRC='/skin/blank.gif'/>"); 43 w.write("<td class='selected-tab-middle'>"); 44 appendLink(w, tab.getName(), baseURL, params, "") ; 45 w.write("</td>"); 46 w.write("<td class='selected-tab-right' SRC='/skin/blank.gif'/>\n"); 47 } else { 48 w.write("<td class='tab-left' SRC='/skin/blank.gif'/>"); 49 w.write("<td class='tab-middle'>"); 50 appendLink(w, tab.getName(), baseURL, params, "") ; 51 w.write("</td>"); 52 w.write("<td class='tab-right' SRC='/skin/blank.gif'/>\n"); 53 } 54 } 55 w.write("</tr></table>\n") ; 56 } else { 57 uiSelectTab = (UIComponent) children.get(0) ; 58 } 59 uiSelectTab.encodeBegin(context) ; 60 uiSelectTab.encodeChildren(context) ; 61 uiSelectTab.encodeEnd(context) ; 62 w.write("</div>"); 63 } 64 } | Popular Tags |