1 Reply Latest reply on Jan 24, 2012 11:25 AM by Omino Yoko

    UIPanelMenu Backingbean not working

    Omino Yoko Newbie

      I tried to create <rich:panelMenu> from backing-bean, but all functions don't work.

      e.g.

      1. Expand-button and collaps-button show at the same time

      2. I can click expand-button and collaps-button, but it doesn't happen

      3. I've disabled the below UIPanelMenuGroup (layout). It shows 2 times righticons

       

      What happens?

      What have I done wrong?

       

      Screenshot - 231838.png

       

       

      .xhtml file

       

      ...
      <h:panelGrid columns="2" width="300" >
            <rich:panelMenu binding="#{myBean.menu}" />
      </h:panelGrid>
      ...
      

       

       

      Managed Bean

       

       

      ...
      private UIPanelMenu menuPanelBinding;
      
      public myBean(){
              initPanelMenu();
      }   
      
      public void initPanelMenu() {
      
      FacesContext facesContext = FacesContext.getCurrentInstance();
              Application application = facesContext.getApplication();
      
              this.menuBinding = (UIPanelMenu) application.createComponent(facesContext, UIPanelMenu.COMPONENT_TYPE, "org.richfaces.PanelMenuRenderer");
              this.menuBinding.setId("id_panelMenu");
      
              //Css
              this.menuBinding.setStyleClass("panelMenu");
              this.menuBinding.setItemClass("panelMenuItem");
      
              //Icon
              this.menuBinding.setItemLeftIcon("none");
              this.menuBinding.setGroupExpandedRightIcon("/resources/images/exanded.png");
              this.menuBinding.setGroupCollapsedRightIcon("/resources/images/collapsed.png");
              this.menuBinding.setTopGroupExpandedRightIcon("/resources/images/exanded.png");
              this.menuBinding.setTopGroupCollapsedRightIcon("/resources/images/collapsed.png");
      
              //Disabled
              this.menuBinding.setDisabled(false);
              this.menuBinding.setGroupDisabledRightIcon("/resources/images/lock.png");
              this.menuBinding.setTopGroupDisabledRightIcon("/resources/images/lock.png");
      
              //Mode
              this.menuBinding.setGroupMode(PanelMenuMode.server);
              this.menuBinding.setItemMode(PanelMenuMode.server);
      
      
              this.menuBinding.setExpandSingle(false);
              this.menuBinding.getChildren().clear();
              this.menuBinding.getChildren().addAll(buildpanelMenuGroup()); 
          }
      }
      
      public List<UIPanelMenuGroup> buildpanelMenuGroup() {
           List<UIPanelMenuGroup> menuGroups = new ArrayList<UIPanelMenuGroup>();
      
      
           FacesContext facesContext = FacesContext.getCurrentInstance();
           Application application = facesContext.getApplication();
           UIPanelMenuGroup menuGroup1 = (UIPanelMenuGroup) application.createComponent(facesContext, UIPanelMenuGroup.COMPONENT_TYPE, "org.richfaces.PanelMenuGroupRenderer");
      
           menuGroup1.setId(id_panelMenuGroup1);
           menuGroup1.setLabel("Example Data");
      
           //Style
           menuGroup1.setStyleClass("panelMenuGroup1");
      
           //Icon
           menuGroup1.setLeftIconClass("panelMenuGroup1_LeftIcon");
      
           //Disabled
           menuGroup1.setDisabledClass("panelMenuGroup1_Disabled");
      
           menuGroup1.setExpanded(true);
           menuGroup1.setDisabled(false);
           menuGroup1.setHoverClass("panelMenuGroup1_Hover");
           menuGroup1.setRender("id_panelMenuGroup2");
      
           UIPanelMenuItem data_item_1 = (UIPanelMenuItem)application.createComponent(facesContext, UIPanelMenuItem.COMPONENT_TYPE, "org.richfaces.PanelMenuItemRenderer"); 
           data_item_1.setId("id_panelMenuItem1");
           data_item_1.setLabel("Data1");
           data_item_1.addActionListener(new DataMenuListener());
      
           UIPanelMenuItem data_item_2 = (UIPanelMenuItem)application.createComponent(facesContext, UIPanelMenuItem.COMPONENT_TYPE, "org.richfaces.PanelMenuItemRenderer"); 
           data_item_2.setId("id_panelMenuItem2");
           data_item_2.setLabel("Data2");
           data_item_2.addActionListener(new DataMenuListener());
      
           UIPanelMenuItem data_item_3 = (UIPanelMenuItem)application.createComponent(facesContext, UIPanelMenuItem.COMPONENT_TYPE, "org.richfaces.PanelMenuItemRenderer"); 
           data_item_3.setId("id_panelMenuItem3");
           data_item_3.setLabel("Data3");
           data_item_3.addActionListener(new DataMenuListener());
      
      
           UIPanelMenuGroup menuGroup2 = (UIPanelMenuGroup) application.createComponent(facesContext, UIPanelMenuGroup.COMPONENT_TYPE, "org.richfaces.PanelMenuGroupRenderer");  
           menuGroup2.setId("id_panelMenuGroup2");
           menuGroup2.setLabel("Layout");
      
           //Style
           menuGroup2.setStyleClass("panelMenuGroup2");
      
           //Icon
           menuGroup2.setLeftIconClass("panelMenuGroup2_LeftIcon");
      
           //Disabled
           menuGroup2.setDisabledClass("panelMenuGroup2_Disabled");
      
           menuGroup2.setExpanded(false);
           menuGroup2.setDisabled(true);
          ...
      
      }
      
      public void setMenu(UIPanelMenu menu) {
            this.menuBinding = menu;
      }
      
      public UIPanelMenu getMenu() {
           return this.menuBinding;
      }
      
        • 1. Re: UIPanelMenu Backingbean not working
          Omino Yoko Newbie

          It works now

           

           

          At the begining I've create a component without renderer

           


          this.menuBinding = (UIPanelMenu) application.createComponent(UIPanelMenu.COMPONENT_TYPE)
          

           

          now

           


          this.menuBinding = (UIPanelMenu) application.createComponent(facesContext, UIPanelMenu.COMPONENT_TYPE, "org.richfaces.PanelMenuRenderer");
          

           

           

          and then

           

           

          public void setMenu(UIPanelMenu menu) {
                  this.menuBinding = menu;
          }
          
          public UIPanelMenu getMenu() {
                  initPanelMenu(); // always rerender panelmenu
                  return menuBinding;
          }
          

           

           

           

          BUT (new problem)

           

          I've set

           

          this.menuBinding.setGroupMode(PanelMenuMode.ajax);
          this.menuBinding.setItemMode(PanelMenuMode.ajax);
          
          ....
          
          data_item_1.setRender("id_panelMenuGroup2");
          
          
          

           

           

           

          When I select for example data_item_1, the listening-content is not changed

           

          Can someone explain how to use .setRender(Object o)?