0 Replies Latest reply on Jun 6, 2008 12:35 PM by Alexandre GOMES ESTELA

    [MenuItem and DropDownMenu] Rerendering problems

    Alexandre GOMES ESTELA Newbie

      Hi all,

      I'm new to richfaces, and I can't succed to correctly rerender single menuItems inside a dropDownMenu. I don't know yet if it is a bug or something I missed in the documentation :) I'm using richfaces-3.2.1.GA, facelets-1.1.13 and the mojarra-1.2_09-b01 JSF implementation.

      Here's the point : I would like to change the value (label) of a menuItem component (in a dropDownMenu) when the user selects it. When the menuItem is selected, an action is called from a backing bean to update the same menuItem's label. Therefore, once the view is restored and the page reloaded, the menuItem should have its label updated (If I got it right).

      This doesn't work, either I use the server or ajax submit mode for my menuItem (in case of ajax, I tell the menuItem to rerender itself). The action method is called correctly, so is the setValue method on the menuItem, but its label is not updated in the page.

      Notes :
      - my menu and its menu items are all dynamically created in the backing bean
      - I can't manage neither to rerender the label of a second menuItem, different from the one which calls the action ; indeed, I don't rerender menuItems at all :/
      - but I DO manage to rerender the label of the dropDownMenu which contains the menuItem ! I use exactly the same code, the only difference is the component on which I call the setValue method.

      By the way, I noticed that when migrating to 3.2.0.SR1 to 3.2.1, the rerendering of dropDownMenus (HtmlDropDownMenu component) was different : in case of ajax submission, my dropDownMenu label is rerendered with extra space under it : the label text is shown in its own line like it was before, but another blank line now appears just under it. This problem does not appear when using server submission, or with 3.2.0.SR1.

      For my original menuItem rerendering problem, I put the code hereafter ; in this example, I use the ajax submission mode to try to rerender the menuItem which was selected.

      A simplified version of my backing bean (called "menu") :

      public class MenuBackingBean {
      
       private HtmlDropDownMenu menuWindow;
       private HtmlMenuItem menuShowHideConsole;
      
       public MenuBackingBean() {
      
       menuWindow = new HtmlDropDownMenu();
       menuWindow.setValue("Window");
      
       menuShowHideConsole = new HtmlMenuItem();
       menuShowHideConsole.setValue("Hide console");
       menuShowHideConsole.setSubmitMode("ajax");
       menuShowHideConsole.setId("idMenuShowHideConsole");
       menuShowHideConsole.setReRender("idMenuShowHideConsole");
       menuShowHideConsole.setActionExpression(FacesUtils.createMethodExpression("#{menu.switchConsole}", String.class, new Class[0]));
       menuWindow.getChildren().add(menuShowHideConsole);
       }
      
       public String switchConsole() {
       menuShowHideConsole.setValue("Show console");
       return null;
       }
      
       public HtmlDropDownMenu getMenuWindow() {
       return menuWindow;
       }
       public void setMenuWindow(HtmlDropDownMenu menuWindow) {
       this.menuWindow = menuWindow;
       }
      }
      


      And in my jsp :

      <rich:dropDownMenu id="mainMenuWindow" binding="#{menu.menuWindow}" showDelay="0" />
      


      Any help greatly appreciated !
      Alexandre