-
1. Re: panelMenu as page navigation
joergvf Dec 21, 2007 12:24 PM (in response to joergvf)I understand now that I have to keep the expanded state of panelMenuGroups in a session-scoped bean. I succeeded to initially get one menuGroup opened by having a managed-bean navigationController with a Map<String,Boolean> property called expandedMenus:
<rich:panelMenuGroup expanded="#{navigationController.expandedMenus['transportdaten']}" label="Transportdaten">
The above panelMenuGroup will be opened when I display the page. However, I don't succeed in keeping the expanded state that the user selected across menu selections, using the following:<h:form id="navigationForm"> <rich:panelMenu style="width:200px" submitMode="none" mode="none" iconExpandedGroup="disc" iconCollapsedGroup="disc" iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right"> [..] <rich:panelMenuGroup expanded="#{navigationController.expandedMenus['stammdaten']}" label="Stammdaten"> <rich:panelMenuGroup expanded="#{navigationController.expandedMenus['kraftfahrzeuge']}" label="Kraftfahrzeuge"> <rich:panelMenuItem id="neuErfassen" name="neuErfassen" label="Neu erfassen" action="#{fahrzeugController.createNewFahrzeug}"> </rich:panelMenuItem> <rich:panelMenuItem id="uebersicht" name="uebersicht"> <h:commandLink action="#{fahrzeugController.fahrzeuge}">Übersicht</h:commandLink> </rich:panelMenuItem> </rich:panelMenuGroup> </rich:panelMenuGroup> </rich:panelMenu> </h:form>
My suspicion is that the expanded attribute values are not submitted correctly, even though I put the panelMenu into a form and tried both a panelMenuItem with action as well as a commandLink. Neither seems to transmit the expanded state.
There is some confusion in the documentation about whether it is "mode" or "submitMode", and I tried both with "none" and "server" ("ajaxx" gives other problems).
Can anybody give a working example for keeping the expanded state across panelMenuItem selections? -
2. Re: panelMenu as page navigation
ilya80 Dec 24, 2007 7:32 AM (in response to joergvf)i second that, a working example (and perhaps a bit more simple than richfaces-demo) would be great
-
3. Re: panelMenu as page navigation
ilya80 Dec 25, 2007 6:29 AM (in response to joergvf)Okay, i was messing around with that and here is the workaround i came up with:
To use partial page navigation with navigation elements located out of navigated content (a.k.a. panelMenu as naviation) i had to create a session scoped bean that was responsible for dishing out "full context-relative path of the resource" for the a4j:include viewId attribute. No navigation rules are used in that approach.
I`m not sure if this is the best way to handle such cases or if it its valid at all. I made the id's in the included pages different to avoid any trouble.
Here is a very silly sample:
---------------- from bean source ----------------
public class ComponentNavigator {
private String currentPagePath;
public ComponentNavigator() {
this.currentPagePath = "components/page1.jspx";
}
public String getCurrentPagePath() {
return currentPagePath;
}
public void viewFirstPage(ActionEvent event) {
currentPagePath = "components/page1.jspx";
}
public void viewSecondPage(ActionEvent event) {
currentPagePath = "components/page2.jspx";
}
}
---------------- from faces-config xml ----------------
<managed-bean>
<managed-bean-name>componentNavigator</managed-bean-name>
<managed-bean-class>demo.ComponentNavigator</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
---------------- from main.jspx ----------------
<f:view>
<h:form>
<a4j:commandButton value="First Page" actionListener="#{componentNavigator.viewFirstPage}" reRender="insertedpage"/>
<a4j:commandButton value="Second Page" actionListener="#{componentNavigator.viewSecondPage}" reRender="insertedpage"/>
<a4j:include viewId="/WEB-INF/#{componentNavigator.currentPagePath}" id="insertedpage" rendered="true"/>
</h:form>
</f:view>
---------------- from page1.jspx ----------------
<rich:panel header="Simple Echo"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
id="richpanel1" >
<h:inputText value="#{bean.name}" id="in1">
<a4j:support event="onkeyup" reRender="outtext1" id="sup1"/>
</h:inputText>
<h:outputText id="outtext1" value="OUTTEXT1: #{bean.name}" />
</rich:panel>