2 Replies Latest reply on Aug 5, 2010 12:14 PM by ZJ DA

    setSelectedChild for rich:panelMenu does not work, Bug?

    ZJ DA Newbie

      Hi, I want to programmatically call setSelectedChild for rich:panelMenu and find out the panelMenu is not refreshed for right style.  The following is my test code:

       

      .rich-pmenu-selected-element{
          font-weight:bold !important;
      }

       

      ...

       

      <f:view>
          <h:panelGrid columns="2" columnClasses="colNav, colContent" width="100%">
          <rich:panel id="leftPanel"
              style="vertical-align:top; margin:0px; padding:0px; height:250px; width:100%; overflow:auto;">
          <a4j:form id="menuform">
          <rich:panelMenu id="menuPanel" mode="ajax"
              selectedChild="#{panelMenu.selectedMenuItem}" binding="#{panelMenu.panelMenu}"
              iconExpandedGroup="disc" iconCollapsedGroup="disc"
              iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
              iconCollapsedTopGroup="chevronDown">

              <rich:panelMenuGroup label="Group 1" id="group1" value="#{panelMenu.menu['group1']}">
                  <rich:panelMenuItem id="item11" label="Item 1.1" actionListener="#{panelMenu.select}" reRender="setectedId, rightPanel">
                  </rich:panelMenuItem>
                  <rich:panelMenuItem id="item12" label="Item 1.2" actionListener="#{panelMenu.select}" reRender="setectedId, rightPanel">
                  </rich:panelMenuItem>
              </rich:panelMenuGroup>
          </rich:panelMenu>
          </a4j:form>
          <h:outputText id="setectedId" value="#{panelMenu.selectedMenuItem}"></h:outputText>
          </rich:panel>
             
           <rich:panel id="rightPanel"
               style="position:relative; vertical-align:top;margin:0px; padding:0px; border: 1; height:400px; overflow: auto;">
              <a4j:form id="contentform">
                  <a4j:commandButton id="butClose" value="Close" reRender="leftPanel, rightPanel" >
                      <a4j:actionparam name="selectedMenuItem" value="item11" assignTo="#{panelMenu.selectedMenuItem}" />
                  </a4j:commandButton>
                  <br/>
                  <h:outputText value="#{panelMenu.selectedMenuItem}"></h:outputText>
              </a4j:form>           
          </rich:panel>
          </h:panelGrid>
      </f:view>

       

      After I click "Item 1.2", the both of outputText show "item12".  Then after clicking "Close" button, the both of outputText show "item11", which is correct.  However, "Item 1.2" is still rendered with the selected style (BOLD), and "Item 1.1" is still "plain".  I am using RF 3.3CR1.  Is it a bug or do I miss someting?

       

      Here is my session back bean:

       

      public class PanelMenu {
          private Map <String, Boolean> menu;
          private String selectedMenuItem = "item11";
          private HtmlPanelMenu panelMenu;
          
         
          public HtmlPanelMenu getPanelMenu() {
              return panelMenu;
          }

          public void setPanelMenu(HtmlPanelMenu panelMenu) {
              this.panelMenu = panelMenu;
          }

          public String getSelectedMenuItem() {
              return selectedMenuItem;
          }
         
          public Map<String, Boolean> getMenu() {
              return menu;
          }   
            
          public void setMenu(Map<String, Boolean> menu) {
              this.menu = menu;
          }
         
          public void setSelectedMenuItem(String selectedMenuItem) {
              this.selectedMenuItem = selectedMenuItem;
              this.panelMenu.setSelectedChild(selectedMenuItem);
          }
         
          @PostConstruct
          public void init () {
              menu = new HashMap <String, Boolean>();
              menu.put("group1", false);
          }

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

      }

       

      Thank you for looking at issue.

       

      -ZJ

        • 1. Re: setSelectedChild for rich:panelMenu does not work, Bug?
          Ilya Shaikovsky Master

          yes seems there is a problem with selectedChild. please change it to value. This worked for me:

           

          <rich:panelMenu style="width:200px"  mode="ajax"  
          iconExpandedGroup="disc" iconCollapsedGroup="disc" id="pm"  
          iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" 
          iconCollapsedTopGroup="chevronDown" value="#{userBean.name}"> <!-- not working if use selectedChild="#{userBean.name}" -->
          <rich:panelMenuGroup label="Item 1.1" name="i1" id="i1">
          <f:param name="current" value="Item 1.1"/>
          </rich:panelMenuGroup>
          <rich:panelMenuGroup label="Item 1.2" name="i2" id="i2">
          <f:param name="current" value="Item 1.2"/>
          </rich:panelMenuGroup>
          </rich:panelMenu>
          </h:panelGrid>
          <a4j:commandButton value="set 2" reRender="pm">
          <a4j:actionparam name="p" value="i2" assignTo="#{userBean.name}"></a4j:actionparam>
          </a4j:commandButton>
          
          • 2. Re: setSelectedChild for rich:panelMenu does not work, Bug?
            ZJ DA Newbie

            Hi Ilya,

             

            After I changed "selectedChild" to "value", it works perfect.

             

            Thank you very much for looking at the issue,

             

            -ZJ