4 Replies Latest reply on Apr 9, 2010 4:28 PM by samuel contreras

    ReRendering menuItem

    Hans Huber Newbie

      hello,

      i'm trying to rerender a menuItem when it was clicked (menuItem acts as a toggle). the menu is created programatically in a backing bean.

      this is the jsf-page:

      <rich:dropDownMenu id="menu" value="Group A"
       binding="#{backingBean.menu}">
      </rich:dropDownMenu>
      


      i call menuITem.setReRender("menu") on the created menuItems but this does not seam to work.

      how can i force the menu to be rerendered when a menu item is clicked?
      any help is very much appreciated.

      kind regards,

      oliver

        • 1. Re: ReRendering menuItem
          Ilya Shaikovsky Master

          look this simpel test works for me:

          <h:form id="menu">
           <rich:toolBar>
           <rich:dropDownMenu binding="#{menucomponent.downMenu}"/>
           </rich:toolBar>
           </h:form>


          private HtmlDropDownMenu downMenu;


           private HtmlDropDownMenu downMenu;
          public String createMenu() {
           downMenu = new HtmlDropDownMenu();
           downMenu.setValue("label");
           downMenu.setSubmitMode("ajax");
           downMenu.setId("menu");
           HtmlMenuItem menuItem = new HtmlMenuItem();
           menuItem.setValue("first item");
           menuItem.setReRender("menu");
           FacesContext facesContext = FacesContext.getCurrentInstance();
           menuItem.setActionExpression(facesContext.getApplication()
           .getExpressionFactory().createMethodExpression(
           facesContext.getELContext(),
           "#{menucomponent.addItem}", String.class, new Class[0]));
          
           downMenu.getChildren().add(menuItem);
           return "/menu.xhtml";
           }
           public HtmlDropDownMenu getDownMenu() {
           return downMenu;
           }
          
           public void setDownMenu(HtmlDropDownMenu downMenu) {
           this.downMenu = downMenu;
           }
          
           public String addItem() {
           HtmlMenuItem menuItem = new HtmlMenuItem();
           menuItem.setValue("new item");
           menuItem.setReRender("menu");
           downMenu.getChildren().add(menuItem);
           return null;
           }


          every time I click first item - new Item appears inside.

          • 2. Re: ReRendering menuItem
            Ilya Shaikovsky Master

            create menu called from the previous page action

            • 3. Re: ReRendering menuItem
              Hans Huber Newbie

              thank you for your reply. it brought me onto the right track. rerendering now works fine.

              cheers,

              oliver

              • 4. Re: ReRendering menuItem
                samuel contreras Novice

                excellenttttttt!!!!!!!