KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > nav > renderer > html > ExoEditPortalModeMenuRenderer


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.portlets.nav.renderer.html;
6
7 import java.io.IOException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9
10 import javax.faces.component.UIComponent;
11 import javax.faces.context.FacesContext;
12 import javax.faces.context.ResponseWriter;
13 import org.exoplatform.portlets.nav.component.UIMenu;
14 import org.exoplatform.portlets.nav.component.UINavigation;
15 import org.exoplatform.services.portal.model.Node;
16 /**
17  * Thu, May 5, 2004 @ 15:38
18  * @author: Tuan Nguyen
19  * @email: tuan08@users.sourceforge.net
20  * @version: $Id: ExoEditPortalModeMenuRenderer.java,v 1.7 2004/10/19 13:20:03 benjmestrallet Exp $
21  */

22 public class ExoEditPortalModeMenuRenderer extends ExoMenuRenderer {
23   
24   protected void renderNode(ResponseWriter w, UIMenu uiMenu, ResourceBundle JavaDoc res,
25                                   Node node, String JavaDoc ownerURI) throws IOException JavaDoc {
26     int childrenSize = node.getChildrenSize();
27     if (childrenSize == 0) return;
28     w.write("<ul>");
29     for (int i = 0; i < childrenSize; i++) {
30       Node child = node.getChild(i);
31       if(!child.isVisible()) continue ;
32       if (child.getChildrenSize() > 0) {
33         if (child.isSelectedPath()) {
34           w.write("<li class='expanded-child'>");
35         } else {
36           w.write("<li class='collapsed-child'>");
37         }
38       } else {
39         w.write("<li class='leaf'>");
40       }
41       w. write("<a HREF='"); w.write(ownerURI); w.write(child.getUri()); w.write("'>") ;
42       w. write(child.getResolvedLabel()) ;
43       w. write("</a>") ;
44       if (child.isSelectedPath()) {
45         renderNode(w, uiMenu, res, child, ownerURI);
46       }
47       w.write("</li>");
48     }
49     w.write("</ul>");
50   }
51
52   protected void renderAdmin(ResourceBundle JavaDoc res, ResponseWriter w, UIMenu uiMenu) throws IOException JavaDoc {
53     UIComponent uiChild = uiMenu.getUIToolbarPortal();
54     uiChild.encodeBegin(FacesContext.getCurrentInstance());
55     uiChild.encodeChildren(FacesContext.getCurrentInstance());
56     uiChild.encodeEnd(FacesContext.getCurrentInstance());
57   }
58 }
Popular Tags