问题
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: MyClient.panelMenu@2966a5.updateCurrent()
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)
回答1:
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
来源:https://stackoverflow.com/questions/2335058/richfaces-richpanelmenu-from-rf-demo-causes-error