2 Replies Latest reply on Sep 19, 2007 1:08 AM by wj lu

    How to update PanelMenu  dynamically ?

    wj lu Newbie

      I created a PanelMenu in a page and then bind to a managed bean, then create sub menu groups and items dynamically in code. Like this:

      1. Part of mypage.xhtml
      ---------------------------------------------

      <rich:panelMenu style="width:200px" mode="ajax" binding="#{subscriptionList.panelMenu}"
      iconExpandedGroup="disc" iconCollapsedGroup="disc"
      iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
      iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" id="panelMenu"/>

      ------------------------------------------------

      2. Part of SubscriptionList.java
      -----------------------------------------------
      public class SubscriptionList extends BasePage implements Serializable {

      ...

      private HtmlPanelMenu panelMenu;

      public HtmlPanelMenu getPanelMenu() {
      System.out.println("GetPanelMenu");
      if (panelMenu == null) {
      panelMenu = new HtmlPanelMenu();
      }
      panelMenu.getChildren().clear();
      List groups = getPanelMenuGroups();
      menu.getChildren().addAll(groups);

      return panelMenu;
      }

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

      public SubscriptionList() {
      }

      protected List getPanelMenuGroups() {
      ...
      return groups;
      }

      }

      ----------------------------------------------------------
      These code work correctly. The problem is that when I updated the menu items in other places I need to update the PanelMenu also, but I found that the function "getPanelMenu()" was called only once in one session. It seems that the binding-value was stored somewhere in the current session. So, How can I modify this object? Is there other ways to update the component dynamically?

      Thanks!