我在index.jsp页面中逐字地获得了RichFaces演示panelMenu source。由于演示不提供支持此源的任何支持bean代码,因此我在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;
}
当我运行它时,导航菜单很好,但选择一个项目以在菜单右侧的框中输出所选元素文本会导致错误:
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
谁能告诉我为什么? (Tomcat 6,RichFaces 3.3.2 SR1)
答案 0 :(得分:2)
您的方法不得有任何参数。它应该看起来像这样(从演示应用程序源复制):
public String updateCurrent() {
FacesContext context = FacesContext.getCurrentInstance();
setCurrent((String) context.getExternalContext()
.getRequestParameterMap().get("current"));
return null;
}
<f:param>
不会添加方法参数。它添加了请求参数。
可以从http://anonsvn.jboss.org/repos/richfaces/tags/3.3.1.GA/samples/richfaces-demo
签出来源