4 Replies Latest reply on Sep 20, 2011 3:28 PM by simkam

    RichFaces 4 and keeping panelMenu state

    siteburn Newbie

      Hello,

       

      i would like to keeping the state of the menu, when i click on a "panelMenuItem" with an "action-Attribut", look at my following example (Item 1.1 with an action-Attribut).

       

      <rich:panelMenu style="width:200px" itemMode="ajax" groupMode="ajax"
          groupExpandedLeftIcon="triangleUp"
          groupCollapsedLeftIcon="triangleDown"
          topGroupExpandedRightIcon="chevronUp"
          topGroupCollapsedRightIcon="chevronDown" itemLeftIcon="disc">
          <rich:panelMenuGroup label="Group 1">
              <rich:panelMenuItem label="Item 1.1" name="Item_1_1" action="myTest"/>
              <rich:panelMenuItem label="Item 1.2" name="Item_1_2" />
              <rich:panelMenuItem label="Item 1.3" name="Item_1_3" />
          </rich:panelMenuGroup>
      </rich:panelMenu>
      

       

      I tried this: http://www.shareyourwork.org/roller/ralphsjavablog/entry/richfaces_panelmenu_how_to_save but no success!

       

      please someone can help me?

       

      thanks.

       

      greez siteburn

        • 1. Re: RichFaces 4 and keeping panelMenu state
          siteburn Newbie

          no solution or workaround for this problem?

           

          at the richfaces-showcase-menu on http://richfaces-showcase.appspot.com/ is the expand state of the left menu save, but how? It's a dynamically created menu...

          • 2. Re: RichFaces 4 and keeping panelMenu state
            simkam Newbie

            Hi,

             

            you can look at showcase sources here: http://anonsvn.jboss.org/repos/richfaces/trunk/examples/richfaces-showcase/

            also look at activeItem attribute of rich:panelMenu and expanded attribute of rich:panelMenuGroup

            • 3. Re: RichFaces 4 and keeping panelMenu state
              siteburn Newbie

              thanks for you answer.

               

              i looked at the navigation.xhtml (template), but no expanded attribute at rich:panelMenuGroup, but a "activeItem" attribute at rich:panelMenu.

               

              code of navigation.xhtml:

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:c="http://java.sun.com/jsp/jstl/core">
                  <rich:panelMenu activeItem="#{demoNavigator.currentDemo.id}">
                      <c:forEach items="#{demoNavigator.groups}" var="gr">
                          <rich:panelMenuGroup label="#{gr.name}"
                              rightExpandedIcon="#{gr.newItems ? '/images/icons/new-ic.gif' : null}"
                              rightCollapsedIcon="#{gr.newItems ? '/images/icons/new-ic.gif' : null}">
                              <c:forEach items="#{gr.demos}" var="d">
                                  <rich:panelMenuItem label="#{d.name}" action="#{d.id}"
                                      mode="client" name="#{d.id}"
                                      rightIcon="#{(d.newItems || gr.newItem) ? '/images/icons/new-small-ic.gif' : null}"
                                      onclick="document.location.href='#{facesContext.externalContext.requestContextPath}/richfaces/component-sample.jsf?demo=#{d.id}&amp;skin=#{skinBean.skin}'">
                                  </rich:panelMenuItem>
                              </c:forEach>
                          </rich:panelMenuGroup>
                      </c:forEach>
                  </rich:panelMenu>
              </ui:composition>
              

               

              the navigation beans are there http://anonsvn.jboss.org/repos/richfaces/trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/common/navigation/

               

              But i can't find or understand the right codesegment for saving the menu state. It's to complex for my application.

               

              can you help me to find the right code?

               

              thanks.

              • 4. Re: RichFaces 4 and keeping panelMenu state
                simkam Newbie

                Just save active item in session scoped managed bean. PanelMenuGroup with active item will stay expanded. In theory, I can't try it now.