3 Replies Latest reply on May 23, 2014 4:01 AM by Michal Petrov

    [RF 4.3.5.final] panelmenu loses selected menuItem

    Tanja Schöberl Newbie

      Hello!

       

      I am using rich:panelmenu with itemMode="server". If I click on a panelMenuItem the background-color of the selected MenuItem should change.

      I have the stylingClass:

      .rf-pm-itm-sel {

          background-color: #CCCCCC;

      }

       

      But when I click on a panelMenuItem the whole page is reloaded and so the menuItem only has the styleClass: "rf-pm-itm"

       

      If I use the itemMode="ajax", the selected menuItem has the correct styleClass.

       

      Is there a possibility to use itemMode="server" and to use the rf-pm-itm-sel styleClass?

       

      Thanks and regards,

      Tanja

        • 1. Re: [RF 4.3.5.final] panelmenu loses selected menuItem
          Michal Petrov Master

          Hi,

           

          I tested that and it works fine for me. What does your menu look like?

          • 2. Re: [RF 4.3.5.final] panelmenu loses selected menuItem
            Tanja Schöberl Newbie

            My xhtml:

            <ui:composition lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"

                xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich" mlns="http://www.w3.org/1999/xhtml">

                <h:head />

                <h:body>

                    <h:panelGrid border="0" columns="2" columnClasses="colNavigation,colContent">

                        <h:panelGroup>

                            <rich:panel styleClass="navigationPanel">

                                <h:form>

                                    <div class="applicationName">

                                        <h:outputText value="Example" />

                                    </div>

                                    <rich:panelMenu expandSingle="false"  itemMode="server" groupMode="server" >

                                        <rich:panelMenuGroup label="Person" expanded="true" >

                                            <rich:panelMenuItem label="#{msg['menuPage.new']}"   action="#{personController.newPerson}" >

                                            </rich:panelMenuItem>

                                            <rich:panelMenuItem label="#{msg['menuPage.list']}" action="list">

                                            </rich:panelMenuItem>

                                        </rich:panelMenuGroup>

                                   </rich:panelMenu>

                                </h:form>

                            </rich:panel>

                        </h:panelGroup>

                        <h:panelGroup>

                            <ui:insert name="content">

                                <h:outputText value="#{msg['menuPage.welcome']}" />

                            </ui:insert>

                        </h:panelGroup>

                    </h:panelGrid>

                </h:body>

            </ui:composition>

             

            and the action:

            public String newPerson() throws Exception {

                    try {

                        this.logger.trace("newPerson(): Method started.");

                        this.newPerson = new Person();

                        this.disableInput = false;

                        return "newPerson";

                    } catch (Exception e) {

                        throw e;

                    }

                }

             

            and the faces-config.xml:

            <navigation-rule>

                    <from-view-id>*</from-view-id>

                    <navigation-case>

                        <from-outcome>newPerson</from-outcome>

                        <to-view-id>/views/personNew.xhtml</to-view-id>

                    </navigation-case>

                </navigation-rule>

             

            and my personNew.xhtml defines the <ui:define name="content">

             

            Regards

            • 3. Re: Re: [RF 4.3.5.final] panelmenu loses selected menuItem
              Michal Petrov Master

              If you're changing pages then the panelMenu you see after clicking the link is a different copy, so it cannot remember what you clicked. You have to keep track of what the selected item should be - use @activeItem, its value has to be equal to the @name of the menu item.

               

              <rich:panelMenu expandSingle="false"  itemMode="server" groupMode="server" activeItem="#{personController.page}" >
                  <rich:panelMenuGroup label="Person" expanded="true" >
                      <rich:panelMenuItem label="#{msg['menuPage.new']}" name="#{msg['menuPage.new']}" action="#{personController.newPerson(msg['menuPage.new'])}" />
                      <rich:panelMenuItem label="#{msg['menuPage.list']}" action="list" />
                  </rich:panelMenuGroup>
              </rich:panelMenu>
              

               

              public String newPerson(String page) throws Exception {
                  this.page = page;
                  …
              }