KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > renderer > xhtmlmp > NodeTabbedPaneRenderer


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