0 Replies Latest reply on May 24, 2011 3:43 PM by paul_r

    Creating a dynamic drop down menu that is populated when the user clicks on the menu button

    paul_r

      I'm trying to create a dynamic drop down menu that is populated when the user clicks on the menu button.   I can create the drop down menu dynamically when the page is created and displayed but I can't get the drop down menu to update when the menu is expanded.  I put in an 'onexpand' event on the dropDownMenu and then added a jsFunction to render the drop down menu in hopes that the menu would call the 'Menu Bean' to generate a new menu.  But this doesn't work.     It appears that the jsFunction is called but it fails to rerender the menu that it is referencing.  

       

      So, is this the correct way to populate a dropdown menu dynamically when the menu is expanded?   The use case is pretty simple.   I need to make the menu items enabled/disabled based on the selection in a table that the menu is displayed with.  The table selections change in the page without a server request so the page is not redrawn with each change in table state.  The drop down menu items though are created when the page was rendered and the table had no selections in it.  I need to go back to the server to create the drop down menu and update the enabled/disabled menu item button states based on the table selections.

       

         <h:form id="myform2">

            <rich:dropDownMenu binding="#{webmenu.myMenu}" name="Menu1" onexpand="menuExpanded()" />

          </h:form>

        

          <a4j:form>

             <a4j:jsFunction name="menuExpanded" reRender="Menu1" />

         </a4j:form>

       

       

      Thanks for any help or input