3 Replies Latest reply on Dec 25, 2007 6:29 AM by Ilya Kalujny

    panelMenu as page navigation

    Jörg von Frantzius Newbie


      I tried to understand how the richfaces-demo does it, but got lost in all those includes and dynamically generated URLs, unfortunately.

      My question is: how can I use a rich:panelMenu as a page navigation?

      In particular, how can it be achieved that upon clicking on a menuItem, a new page is displayed, while the state of the panelMenu is preserved, i.e. expanded groups keep being expanded?

      Thanks for any hints,

        • 1. Re: panelMenu as page navigation
          Jörg von Frantzius Newbie

          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:


          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"
           <rich:panelMenuItem id="uebersicht" name="uebersicht">
           <h:commandLink action="#{fahrzeugController.fahrzeuge}">Übersicht</h:commandLink>

          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
            Ilya Kalujny Newbie

            i second that, a working example (and perhaps a bit more simple than richfaces-demo) would be great

            • 3. Re: panelMenu as page navigation
              Ilya Kalujny Newbie

              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 ----------------



              ---------------- from main.jspx ----------------


              <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"/>



              ---------------- from page1.jspx ----------------

              <rich:panel header="Simple Echo"
              id="richpanel1" >

              <h:inputText value="#{bean.name}" id="in1">

              <a4j:support event="onkeyup" reRender="outtext1" id="sup1"/>


              <h:outputText id="outtext1" value="OUTTEXT1: #{bean.name}" />