0 Replies Latest reply on Mar 11, 2010 6:35 AM by alanhay

    PanelMenu and Selected Item

    alanhay

      I have a PanelMenu and am have trouble getting it to remember its state between requests, viz when page reloads be expanded with the last selected item shown as selected.

       

                  <rich:panelMenu mode="server"
                     selectedChild="#{menuController.selectedMenuItem}"
                      iconExpandedGroup="disc" iconCollapsedGroup="disc"
                      iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
                      iconCollapsedTopGroup="chevronDown">
                      <rich:panelMenuGroup label="Campaign Management" id="group_2">
                          <rich:panelMenuItem icon="/images/ficons/table_add.png" id="cm_1"
                             actionListener="#{menuController.select}"
                             action="#{campaignController.loadCampaignList}"
                              label="Manage Campaigns"></rich:panelMenuItem>
                          <rich:panelMenuItem icon="/images/ficons/table_multiple.png" id="cm_2"
                          actionListener="#{menuController.select}"
                              action="#{campaignController.loadNewCampaignForm}"
                              label="Create New Campaign"></rich:panelMenuItem>
                      </rich:panelMenuGroup>
                 </rich:panelMenu>

       

      MenuController is a bean in session scope to track state:

       

      public class MenuController
      {
          private String selectedMenuItem;

       

          public String getSelectedMenuItem()
          {
              return selectedMenuItem;
          }

       

          public void select(ActionEvent event)
          {
              selectedMenuItem = event.getComponent().getId();
          }
      }

       

      Debugging would seem to indcate that the code does what  expect [1] the action listener fires, [2] the action method fires and returns the next view, [3] getSelectedMenuItem() fires returning the id of the last selected item.

       

      However when the page relaods the menu is shown in collapsed state.

       

      ???