2 Replies Latest reply on Oct 7, 2008 6:24 AM by marimuthu-a

    How to use <a4j:repeat> inside <rich:dropDownMenu> and  </ri

    marimuthu-a

      Hai,
      we are using Rich faces component.
      We need dropdownmenu dynamically, i got the data from java program but did n't display in view?
      I used the following codes,

      <a4j:repeat value="#{MenuLists.items}" var="oCategory">
       <rich:dropDownMenu>
       <f:facet name="label">
       <h:panelGroup>
       <rich:spacer style="width:1px;height:16px;" styleClass="pic" />
       <h:outputText
       style="width:1px;height:19px;vertical-align: middle;"
       styleClass="pic" value="#{oCategory.name}" />
       </h:panelGroup>
       </f:facet>
       <a4j:repeat var="oModule" value="#{oCategory.module}">
       <rich:menuGroup value="#{oModule.name}">
       </rich:menuGroup>
       </a4j:repeat>
       </rich:dropDownMenu>
       </a4j:repeat>


      First <a4j:repeat> tag is working fine.
      But <a4j:repeat> tag is not run inside <rich:dropDownMenu> tags?
      How to use it?


        • 1. Re: How to use <a4j:repeat> inside <rich:dropDownMenu> and
          ilya_shaikovsky

          c:forEach for facelets or binding for facelets should be used. discussed many times in other threads.

          • 2. Re: How to use <a4j:repeat> inside <rich:dropDownMenu> and
            marimuthu-a

            Thanks ur reply.
            plz give more information about <c:forEach>.
            Is it correct or not(myself use)?
            In JSF...

            <a4j:repeat value="#{MenuLists.items}" var="oCategory">
             <rich:dropDownMenu>
             <f:facet name="label">
             <h:panelGroup>
             <rich:spacer style="width:1px;height:16px;" styleClass="pic" />
             <h:outputText
             style="width:1px;height:19px;vertical-align: middle;"
             styleClass="pic" value="#{oCategory.name}" />
             </h:panelGroup>
             </f:facet>
            
             <c:forEach items="#{oCategory.module}" var="oModule">
             <rich:menuGroup value="#{oModule.name}">
             <c:forEach items="#{oModule.function}" var="oFunction">
             <rich:menuItem submitMode="none" value="#{oFunction.name}"
             onclick="document.location.href='VendorDetailsInsert.jsf'"></rich:menuItem>
             </c:forEach>
             </rich:menuGroup>
             </c:forEach>
            
             </rich:dropDownMenu>
            </a4j:repeat>

            In faces config file..
            <managed-bean>
             <managed-bean-name>MenuLists</managed-bean-name>
             <managed-bean-class>com.erp.admin.MenuLists</managed-bean-class>
             <managed-bean-scope>session</managed-bean-scope>
             </managed-bean>


            MenuLists java class has
            public class MenuLists {
            
             List<category> items = null;
            
             /**
             * @return the items
             */
             public List<category> getItems() {
             items=new ArrayList<category>();
             for(int i=0;i<1;i++)
             {
             category oCategory=new category();
             oCategory.setName("Master");
             ArrayList<Module> module=new ArrayList<Module>();
             for(int j=0;j<3;j++)
             {
             Module oModule=new Module();
             oModule.setName("Customer");
             ArrayList<Function> function=new ArrayList<Function>();
             for(int k=0;k<2;k++)
             {
             Function oFunction=new Function();
             oFunction.setName("Add");
             function.add(oFunction);
             }
             oModule.setFunction(function);
             module.add(oModule);
             }
             oCategory.setModule(module);
             items.add(oCategory);
             }
            
             return items;
             }
            
             /**
             * @param items the items to set
             */
             public void setItems(List<category> items) {
             this.items = items;
             }
            
            
            }


            category and Function are separate class.
            categoty has,
            public class category {
            
             private String name;
            
             private ArrayList<Module> module;
            
             /**
             * @return the name
             */
             public String getName() {
             return name;
             }
            
             /**
             * @param name the name to set
             */
             public void setName(String name) {
             this.name = name;
             }
            
             /**
             * @return the module
             */
             public ArrayList<Module> getModule() {
             System.out.println("getModule "+module);
             return module;
             }
            
             /**
             * @param module the module to set
             */
             public void setModule(ArrayList<Module> module) {
             System.out.println("setModule "+module);
             this.module = module;
             }
            
            }


            and Function has
            public class Function {
             private String name;
            
             /**
             * @return the name
             */
             public String getName() {
             return name;
             }
            
             /**
             * @param name the name to set
             */
             public void setName(String name) {
             this.name = name;
             }
            }



            I need Menus dynamically,These values like customer,Add are taken from DB later(now i hard coded).
            I did n't mention anything in faces config file about category and Function class...
            How to Solve it?