6 Replies Latest reply on Dec 11, 2008 6:00 AM by kus

    Exception using HtmlPanelMenuItem: wrong number of arguments

    kus

      Hi all

      I'm using Richfaces 3.2.2 SR1. I'm creating a MethodExpression and set it on the HtmlPanelMenuItem. If I click on the menu item, my action method is not called - I get an exception: javax.servlet.ServletException: wrong number of arguments.

      Anyone has a solution how to call an action method passing an ActionEvent from the HtmlPanelMenuItem?

      Thanks, Markus

      Backing Bean:

      public class WrongNumberBean {
      
       private HtmlPanelMenu menu;
      
       public HtmlPanelMenu getMenu() {
       if (menu == null) {
       menu = new HtmlPanelMenu();
       HtmlPanelMenuItem menuItem = new HtmlPanelMenuItem();
       menuItem.setId("some_id");
       menuItem.setLabel("test");
       MethodExpression me = FacesContext.getCurrentInstance().getApplication()
       .getExpressionFactory().createMethodExpression(
       FacesContext.getCurrentInstance().getELContext(),
       "#{wrongNumberBean.testAction}", null,
       new Class[] { ActionEvent.class });
       menuItem.setActionExpression(me);
       menu.getChildren().add(menuItem);
       }
       return menu;
       }
      
       public void setMenu(HtmlPanelMenu menu) {
       this.menu = menu;
       }
      
       public void testAction(ActionEvent actionEvent) {
       System.out.println("testAction called");
       }
      }
      


      XHTML
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
       "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:f="http://java.sun.com/jsf/core">
      <head>
      </head>
      <body>
      <!-- safari fix -->
      <f:view contentType="text/html" />
      <h:form>
       <rich:panelMenu binding="#{wrongNumberBean.menu}"/>
      </h:form>
      </body>
      </html>