1 Reply Latest reply on Jan 8, 2009 6:16 AM by Nick Belaevski

    Call action method before refreshing component from binding?

    Johannes Degler Newbie

      I'm using a dynamically created HtmlDropDownMenu. The menu is created by a bean and loaded by binding it with "<rich:dropDownMenu binding="#{...". I've had some problems creating this, but now everything works fine.

      The only problem I still have is that the setter method for the menu binding gets called before the method expression bound to the menu items. This is a problem, because I want to hide items once they were clicked. But to do this the method expression would have to be executed before the binding method.
      I've tried setting immediate and bypassUpdates to true, but this doesn't help.

      Here's the source code:

      <rich:dropDownMenu id="dropDownShowColumns" submitMode="ajax" binding="#{searchService.availableShowColumnsDropDownMenu}"/>

      public void setAvailableShowColumnsDropDownMenu(final HtmlDropDownMenu menu){
      public HtmlDropDownMenu getAvailableShowColumnsDropDownMenu(){
       final HtmlDropDownMenu menu = new HtmlDropDownMenu();
       final FacesContext fc = FacesContext.getCurrentInstance();
       final ExpressionFactory ef = fc.getApplication().getExpressionFactory();
       for(final AbstractShowColumn column : availableShowColumns){
       final HtmlMenuItem item = new HtmlMenuItem();
       final String name = column.getName();
       final MethodExpression me = ef.createMethodExpression(fc.getELContext(), "#{searchService.addShowColumnByName('" + name + "')}", null, new Class[]{String.class});
       return menu;
      private void updateAvailableShowColumnsDropDownMenu(final HtmlDropDownMenu menu){
       final Set<String> visible = new HashSet<String>();
       for(final AbstractShowColumn col : this.getAvailableShowColumns())
       for(final UIComponent c : menu.getChildren())
       if(c instanceof HtmlMenuItem)