KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > nav > renderer > xhtmlmp > HorizontalMenuRenderer


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.xhtmlmp;
6
7 import java.io.IOException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9 import javax.faces.component.UIComponent;
10 import javax.faces.context.FacesContext;
11 import javax.faces.context.ResponseWriter;
12 import org.exoplatform.container.SessionContainer;
13 import org.exoplatform.portal.session.RequestInfo;
14 import org.exoplatform.portlets.nav.component.UINavigation;
15 import org.exoplatform.portlets.nav.renderer.html.ExoMenuRenderer;
16 import org.exoplatform.services.portal.model.Node;
17 import org.exoplatform.services.portal.model.PageReference;
18 /**
19  * Thu, May 5, 2004 @ 15:38
20  *
21  * @author: Tuan Nguyen
22  * @email: tuan08@users.sourceforge.net
23  * @version: $Id: HorizontalMenuRenderer.java,v 1.9 2004/10/07 21:57:17 fichatel Exp $
24  */

25 public class HorizontalMenuRenderer extends ExoMenuRenderer {
26   public void encodeChildren(FacesContext context, UIComponent uiComponent) throws IOException JavaDoc {
27     ResourceBundle JavaDoc res = getApplicationResourceBundle(context.getExternalContext()) ;
28     UINavigation uiMenu = (UINavigation) uiComponent;
29     RequestInfo rinfo = (RequestInfo)SessionContainer.getComponent(RequestInfo.class);
30     String JavaDoc ownerURI = rinfo.getOwnerURI() ;
31     String JavaDoc mimeType = uiMenu.getPreferedMimeType() ;
32     ResponseWriter w = context.getResponseWriter() ;
33     Node selectNode = uiMenu.getSelectedNode() ;
34     w.write(res.getString("UIHorizontalMenu.icon.banner"));
35     w.write("<br/>");
36     w. write("<a HREF='"); w.write(ownerURI); w.write("/home/sitemap"); w.write("'>") ;
37     w. write(res.getString("UIHorizontalMenu.icon.site-map")) ;
38     w. write("</a>") ;
39     for (int i = 0; i < selectNode.getChildrenSize(); i++) {
40       Node node = selectNode.getChild(i);
41       PageReference pref = node.getPageReference(mimeType) ;
42       if(pref == null || pref.isVisible()) {
43         String JavaDoc label = node.getIcon();
44         if(label == null) label = node.getResolvedLabel() ;
45         w. write("<a HREF='"); w.write(ownerURI); w.write(node.getUri()); w.write("'>") ;
46         w. write(label) ;
47         w. write("</a>") ;
48         w.write(' ') ;
49       }
50     }
51   }
52 }
Popular Tags