views:

277

answers:

1

Hello,

I've got the RichFaces demo panelMenu source verbatim in an index.jsp page. As the demo doesn't supply any backing bean code to support this source, I created these methods in panelMenu.java:

public void updateCurrent(String n) {
    logger.info("updateCurrent called with " + n);
    setCurrent(n);
}

public String getCurrent() {
    return current;
}

public void setCurrent(String c) {
    current = c;
}

When I run this, navigating the menu is fine, but selecting an item to output the selected element text in a box to the right of the menu causes an error:

WARNING: Error calling action method of component with id form:j_id_jsp_920730595_6
javax.faces.FacesException: Error calling action method of component with id form:j_id_jsp_920730595_6
    at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)

...

Caused by: javax.faces.el.MethodNotFoundException: org.apache.jasper.el.JspMethodNotFoundException: /index.jsp(27,12) '#{panelMenu.updateCurrent}' Method not found: [email protected]()
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92)
    at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
    ... 28 more

Can anyone tell me why? (Tomcat 6, RichFaces 3.3.2 SR1)

+2  A: 

Your method must not have any arguments. It should look like this (copied from the demo app sources):

public String updateCurrent() {
    FacesContext context = FacesContext.getCurrentInstance();
    setCurrent((String) context.getExternalContext()
         .getRequestParameterMap().get("current"));
    return null;
}

<f:param> doesn't add method arguments. It adds request parameters.

The sources can be checked-out from http://anonsvn.jboss.org/repos/richfaces/tags/3.3.1.GA/samples/richfaces-demo

Bozho
@Mark Lewis check my update
Bozho
@Bozho - can you give me an exact link to that source? The method setCurrent needs copying in too.
Mark Lewis
@Bozho, I don't understand the part of your answer which refers to `f:param`. How is it relevant?
Mark Lewis
`setCurrent` is just a simple setter. The sources can be downloaded from http://www.jboss.org/richfaces/download/stable.html (-examples)
Bozho
`<f:param name="current" value="Item 1.1"/>` is in the code from the example you linked!
Bozho
@Bozho: Ref `f:param`, I now understand what you meant. Thanks
Mark Lewis