1 Reply Latest reply on Oct 15, 2008 5:42 AM by Nick Belaevski

    Dynamically load different dropDownMenu's menuItem upon chan

    Arief ZJ Newbie

      Hi,

      I'm not sure how to start this... but let me just try.

      I'm thinking to have an application which consist of toolbar and main area screen which will accommodate all my screens. Implementation wise, the toolbar could be in a separate iframe and the main area will be in another iframe. If not iframe, maybe we can put it in a div or something.

      Anyway, the big issue now is our toolbar (which consists of rich:dropdownmenu) that should be dynamically changed from screen to screen (in the main area). For example, if we load Screen-A, the dropDownMenu should have 3 menuItems (corresponding to 3 datatable in screen-A). Then, if we load Screen-B, the toolbar dropDownMenu should have 2 menuItems (corresponding to 2 dataTable in screen-B).

      In javascript way, this could be implemented with some event publish / subscribe but i'm not sure how to do it in richfaces/ajax4jsf. I've tried putting the following code after my dataTable:

      <a4j:form>
       <a4j:jsFunction name="updateToolbar" reRender="toolbarNewMenu" ajaxSingle="true" limitToList="true" />
      </a4j:form>
      
      <script type="text/javascript">
       updateToolbar();
      </script>
      


      It seems able to re-render my toolbar component, but how can i make the toolbar re-render based on parameter sent by my dataTable component or any javascript in the main area? After the reRendering the dropDownMenu should have 1 menuItem, received from my dataTable underneath it.

      I know in the component we can specify "binding" element but how can we send parameter to it? And when we load another screen, the previous menuItems should be cleared so that new set of menuItem can be loaded into the toolbar dropDownMenu?

      Many thanks.