1 Reply Latest reply on Jan 23, 2012 8:28 AM by vrelits

    Dynamic Menus in Richfaces 4

    rajkumarsrikanth

      Currently we are working on the migration of Richfaces 3 to Richfaces 4.

      Our project comprises of Spring MVC + Spring Webflow + JSF 2 + Richfaces 4.

      We have used Richfaces version 4.1.0.Final in our project.

       

      We are building the menus dynamically from the database and it is bound to the richfaces toolbar.

       

       

       

       

      @Service
      public
      
      
      
      public UIToolbar getMenuToolbar() {
      if(menuToolbar == null) {
      menuToolbar = new UIToolbar();
      UIDropDownMenu downMenu;
      downMenu = 
      new UIDropDownMenu();UIOutput output = 
      new UIOutput();output.setValue(
      "File");downMenu.getFacets().put(
      "label", output);
      UIMenuGroup menuGroup;
      menuGroup = 
      new UIMenuGroup();menuGroup.setLabel(
      "Save Group");
      UIMenuItem item;
      item = 
      new UIMenuItem();item.setLabel(
      "Save");menuGroup.getChildren().add(item);
      
      item = 
      new UIMenuItem();item.setLabel(
      "Save All");menuGroup.getChildren().add(item);
      
      downMenu.getChildren().add(menuGroup);
      
      
      menuToolbar.getChildren().add(downMenu);}
      
      return menuToolbar;}
      
      
      public void setMenuToolbar(UIToolbar menuToolbar) {
      this.menuToolbar = menuToolbar;}
      }
       class UserService {
      
      private UIToolbar menuToolbar;

       

      The menu is rendered to the HTML, but the java script and CSS files associated with menus are not rendered to the HTML. Hence the menu appears simply like text.

      I have attached the menu layout screen shot.

       

      Thanks in advance

        • 1. Re: Dynamic Menus in Richfaces 4
          vrelits

          Try to put

           

                      <rich:toolbar rendered="false"/>
                      <rich:dropDownMenu rendered="false"/>
                      <rich:menuGroup rendered="false"/>
                      <rich:menuItem rendered="false"/>
                      <rich:toolbar binding="#{menu.toolBar}" height="26px"/>

           

          In your facelet. It's a workaround to load css/js.

          1 of 1 people found this helpful