1 5 package org.exoplatform.portlets.nav.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.ResourceBundle ; 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.ExoPortal; 14 import org.exoplatform.portal.session.RequestInfo; 15 import org.exoplatform.portlets.nav.component.UIMenu; 16 import org.exoplatform.services.portal.model.Node; 17 import org.exoplatform.services.portal.model.PageReference; 18 25 public class ExoMenuTreeRenderer extends ExoMenuRenderer { 26 public void encodeChildren(FacesContext context, UIComponent component) throws IOException { 27 UIMenu uiMenu = (UIMenu) component; 28 ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()) ; 29 ResponseWriter w = context.getResponseWriter(); 30 SessionContainer scontainer = SessionContainer.getInstance() ; 31 ExoPortal portal = (ExoPortal)scontainer.getComponentInstanceOfType(ExoPortal.class) ; 32 RequestInfo rinfo = (RequestInfo)scontainer.getComponentInstanceOfType(RequestInfo.class); 33 String ownerURI = rinfo.getOwnerURI() ; 34 String mimeType = uiMenu.getPreferedMimeType() ; 35 Node root = portal.getRootNode() ; 36 w.write("<a HREF='"); w.write(ownerURI); w.write("'>") ; 37 w. write("Home") ; 38 w.write("</a>") ; 39 w.write("<ul>"); 40 for(int i = 0; i < root.getChildrenSize(); i++){ 41 Node child = root.getChild(i); 42 PageReference pref = child.getPageReference(mimeType) ; 43 if(pref == null || pref.isVisible()) { 44 w.write("<li>"); 45 w. write("<a HREF='"); w.write(ownerURI); w.write(child.getUri()); w.write("'>") ; 46 w. write(child.getResolvedLabel()) ; 47 w. write("</a>") ; 48 encodeNode(child,mimeType, w , ownerURI); 49 w.write("</li>"); 50 } 51 } 52 w.write("</ul>"); 53 renderAdmin(res, w, uiMenu); 54 } 55 56 public void encodeNode(Node node, String mimeType, ResponseWriter w, String ownerURI) throws IOException { 57 w.write("<ul>"); 58 for (int n = 0; n < node.getChildrenSize(); n++) { 59 Node child = node.getChild(n); 60 PageReference pref = child.getPageReference(mimeType) ; 61 if(pref == null || pref.isVisible()) { 62 w.write("<li>"); 63 w. write("<a HREF='"); w.write(ownerURI); w.write(child.getUri()); w.write("'>") ; 64 w. write(child.getResolvedLabel()) ; 65 w. write("</a>") ; 66 encodeNode(child, mimeType, w, ownerURI); 67 w.write("</li>"); 68 } 69 } 70 w.write("</ul>"); 71 } 72 } | Popular Tags |