3 Replies Latest reply on Jan 9, 2008 5:45 PM by Nick Belaevski

    PanelMenu problem with dynamic creation of menu items

    Cristiane Yaguinuma Newbie

      Hello list,

      I'm trying to create a panel menu dynamically, but it is not working. When user clicks on a commandLink, I have a method that adds a new item group and item to the panelMenu, it works well but sometimes the new item is not added or replaces the previous added item. Please, can anyone help me with this problem?


      Cristiane Yaguinuma.

        • 2. Re: PanelMenu problem with dynamic creation of menu items
          Cristiane Yaguinuma Newbie

          Hello Nick, thanks for your answer.

          I have changed my code to use a h:PanelGrid with SimpleTogglePanels instead of PanelMenu, but I still have the same problem, some panels are not created dynamically, others replaces previous ones.

          I have a tree, each node is a commandLink:

          <a4j:commandLink reRender="chatTestPanel" value="#{contact.name}" action="#{ContactList.actionContactClick}">
           <a4j:actionparam name="selectedContact" value="#{contact.id}"/>

          In backing bean I add a new SimpleTogglePanel to a PanelGrid in the method ContactList.actionContactClick:

          public void actionContactClick() {
           String contactId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("selectedContact");
           HtmlSimpleTogglePanel panel = new HtmlSimpleTogglePanel();
           panel.setId("id_" + this.idCount);

          In the code above, this.chatWindowPanelGrid is binded to a h:PanelGrid defined in jsp. This PanelGrid is empty at first and then is filled by the previous method. The problem is that some panels are not added to this.chatWindowPanelGrid.getChildren() and sometimes panels are replaced. I tried an alternative solution, at least is working but I need to test more. I have a list called chatList in my backing bean that keeps the chatWindowPanelGrid children:


          By doing this, chatWindowPanelGrid contains all panels added in the correct order. So, the problem is related to the children list of PanelGrid, the same problem I had with PanelMenu children.

          Again, thanks for the help.

          Cristiane Yaguinuma.

          • 3. Re: PanelMenu problem with dynamic creation of menu items
            Nick Belaevski Master

            Hmm, I do not see anything that could cause the problem. Could you please prepare sample project to see the problem? You can send it to nbelaevski at exadel dot com