1 Reply Latest reply on Mar 4, 2008 12:38 PM by dfsdf dfdsfs

    PanelMenu and PanelMenuGroup problem

    dfsdf dfdsfs Newbie

      Hi All,
      I'm a new user to richfaces and to Java alltogether, and I find it difficult to use PanelMenu generated by backing bean.

      My JSP code look like this:

      <h:form>
       <rich:panelMenu style="width:200px" mode="server"
       binding="#{bean.panelMenu}" iconExpandedGroup="disc"
       iconCollapsedGroup="disc" iconExpandedTopGroup="chevronUp"
       iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown">
       <rich:panelMenuGroup label="USA"/>
      </h:form>


      And relevant part of my bean is the following:
      public HtmlPanelMenu getPanelMenu() {
       if (panelMenu == null) {
       panelMenu = new HtmlPanelMenu();
       panelMenu.setExpandMode("server");
       for (int c = 1; c < 3; c++) {
       System.out.println("adding: " + c);
       HtmlPanelMenuGroup menuCustomerGroup = new HtmlPanelMenuGroup();
       menuCustomerGroup.setExpanded(false);
       menuCustomerGroup.setExpandMode("ajax");
       menuCustomerGroup.setName("Customer " + c);
       menuCustomerGroup.setLabel("Customer " + c);
       panelMenu.getChildren().add(menuCustomerGroup);
       for (int f = 1; f < c + 2; f++) {
       System.out.println("adding: " + f);
       HtmlPanelMenuGroup menuFabGroup = new HtmlPanelMenuGroup();
       menuFabGroup.setExpanded(false);
       menuFabGroup.setExpandMode("server");
       menuFabGroup.setName("Fab " + c + "." + f);
       menuFabGroup.setLabel("Fab " + (c * 10 + f));
       panelMenu.getChildren().add(menuFabGroup);
       for (int i = 1000 + c + f; i < 1000 + c + f + 3; i++) {
       System.out.println("adding: " + i);
       HtmlPanelMenuItem menuMachine = new HtmlPanelMenuItem();
       menuMachine.setName("m"
       + (c + "." + f + "." + (i - 1000)));
       menuMachine.setLabel("m"
       + (c * 1000 + f * 100 + (i - 1000)));
       menuMachine.addActionListener(new ActionListener() {
       public void processAction(final ActionEvent event) {
       System.out.println("processing");
       }
       });
       panelMenu.getChildren().add(menuMachine);
       }
       }
       }
       }
       return panelMenu;
      }
      

      But I do not get what I expected as the result.
      Menu groups are not nested, menu items are at the same level as menu groups and beside that the rendered page crashes as soon as I click on any item.

      Could anybody share a piece of working code for nested panelmenu backing bean or point out what am I doing wrong?
      Any help will be appreciated.
      Thanks in advance,
      Barmalini