This content has been marked as final.
Show 4 replies
-
1. Re: controlling rich:menu....no end in sight
nbelaevski Jan 20, 2009 9:49 PM (in response to janson12)Hello,
This works well for me:<rich:panelMenu> <rich:panelMenuGroup expanded="#{true}" label="Group 1"> <rich:panelMenuItem label="Item 1" /> <rich:panelMenuItem label="Item 2" /> </rich:panelMenuGroup> <rich:panelMenuGroup expanded="#{true}" label="Group 2"> <rich:panelMenuItem label="Item 1" /> <rich:panelMenuItem label="Item 2" /> </rich:panelMenuGroup> <rich:panelMenuGroup expanded="#{false}" label="Group 3"> <rich:panelMenuItem label="Item 1" /> <rich:panelMenuItem label="Item 2" /> </rich:panelMenuGroup> </rich:panelMenu>
How do you reproduce the issue? -
2. Re: controlling rich:menu....no end in sight
janson12 Jan 21, 2009 4:45 AM (in response to janson12)with rf 3.3.0 (btw. thanks a lot for that version!!) the menu groups behave as expected but the thing with the selected item still doesn't work. i create the menu dynamically and found out that neither
menu.setSelectedChild("#{NavigationMenu.selectedChild}");
normenu.setValueExpression("selectedChild", createValueExpression("#{NavigationMenu.selectedChild}", String.class));
seem to call/get/set the selectedChild value. here's the (simplified) code of the NavigationMenu bean holding the menu:
// Creating the menuprivate void generateMenu () { panelState = new HashMap<String, Boolean>(); menu = new HtmlPanelMenu (); menu.setExpandSingle(true); menu.setId("mainMenu"); menu.setMode("ajax"); menu.setExpandMode("none"); menu.setValueExpression("selectedChild", createValueExpression("#{NavigationMenu.selectedChild}", String.class)); panelMenuGroup = generateSingleMenuGroup("header_01", render_header_01, "path1.jsp"); generateSingleItem("item_01", render_item_01, "folder01/file01.jsp"); menu.getChildren().add(panelMenuGroup); /* do same for all groups and items */ }
// Creates the panelGroup, menu kept simple in this caseprivate HtmlPanelMenuGroup generateSingleMenuGroup (String labelName, boolean rendered, String path) { HtmlPanelMenuGroup tmpGroup = new HtmlPanelMenuGroup(); tmpGroup.setLabel(rb.getString(labelName)); tmpGroup.setRendered(rendered); tmpGroup.setId(labelName); tmpGroup.setName(labelName); tmpGroup.setValueExpression("value", createValueExpression("#{NavigationMenu.panelState['"+labelName+"']}",String.class)); panelState.put(labelName, false); return tmpGroup; }
// Creates the menuItemsprivate void generateSingleItem(String labelName, boolean rendered, String path) { HtmlPanelMenuItem tmpPanelMenuItem = new HtmlPanelMenuItem(); tmpPanelMenuItem.setReRender("ajaxArea"); tmpPanelMenuItem.setIgnoreDupResponses(true); tmpPanelMenuItem.setLimitToList(false); tmpPanelMenuItem.setLabel(rb.getString(labelName)); tmpPanelMenuItem.setId(labelName); tmpPanelMenuItem.setName(labelName); tmpPanelMenuItem.setRendered(rendered); UIParameter fParam = new UIParameter(); fParam.setName(vh.getParamName()); fParam.setValue(path); tmpPanelMenuItem.getChildren().add(fParam); tmpPanelMenuItem.setActionExpression(createActionExpression("#{ViewHandler.viewHandlerAction}")); panelMenuGroup.getChildren().add(tmpPanelMenuItem); }
// Switches to a specific itempublic void switchToBackgroundprocesses(ActionEvent event) { //panelState = new HashMap<String, Boolean>(); //THE GROUPS TO BE CLOSED this.panelState.put("header_01", false); this.panelState.put("header_02", false); /* and so on...*/ // THE GROUPS TO BE OPENED this.panelState.put("header_03", true); // THE ITEM TO BE SHOWN IN ITALICS selectedChild = "item_04"; }
// Should create Creates the value expression, e.g. for the selectedChildprivate ValueExpression createValueExpression(String valueExpression, Class<?> cls) { FacesContext facesContext = FacesContext.getCurrentInstance(); return facesContext.getApplication().getExpressionFactory().createValueExpression( facesContext.getELContext(), valueExpression, cls); }
-
3. Re: controlling rich:menu....no end in sight
janson12 Jan 21, 2009 4:49 AM (in response to janson12)selectedChild is called once at first load. so the value expression itself should be fine.