5 Replies Latest reply on Sep 10, 2009 6:24 AM by nbelaevski

    dynamic DropDownMenu

    javatwo

      Hi, We can construct a dynamic drop down menu from data in database.

      such as

      Student
      --------
      John
      Allen
      Smith

      <rich:menuItem action="#{bean.showPerson}" />

      does the menuItem takes a parameter that specify which person to show?
      if not, how to deal with this issue?

      Thanks
      Dave

        • 1. Re: dynamic DropDownMenu
          nbelaevski

          Hi Dave,

          You can use c:forEach tag to do that.

          • 2. Re: dynamic DropDownMenu
            javatwo

            Thanks for reply.
            c:forEach can list all the menuItems. But when a menuItem is clicked, the method bean.showPerson() is called, but it does not know which person, John, Allen, or Smith, ... . If the menuItem can take a parameter, it will solve the problem. Thanks for further help.

            Dave

            • 3. Re: dynamic DropDownMenu
              javatwo


              <rich:dropDownMenu ...>
              <c:forEach var="person" value="#{bean.personList}">

              <rich:menuItem value="#{person.name}" action="#{bean.showPerson}" />

              </c:forEach>

              </rich:dropDownMenu>

              • 4. Re: dynamic DropDownMenu
                javatwo

                <rich:dropDownMenu ...>
                <c:forEach var="person" value="#{bean.personList}">

                <rich:menuItem value="#{person.name}" action="#{bean.showPerson}" >

                <h:param name="personName" value="#{person.name}" />

                </rich:menuItem>

                </c:forEach>

                </rich:dropDownMenu>

                I wish <rich:menuItem> can take h:param

                • 5. Re: dynamic DropDownMenu
                  nbelaevski

                  - Call action method just at person
                  - Menu items should accept and understand parameter tags well