本文介绍了RF演示中的RichFaces rich:panelMenu导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有RichFaces演示在index.jsp页面上逐字逐行显示panelMenu源.由于该演示程序不提供任何支持该源代码的支持Bean代码,因此我在panelMenu.java中创建了这些方法:

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

谁能告诉我为什么? (Tomcat 6,RichFaces 3.3.2 SR1)

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

推荐答案

您的方法不得包含任何参数.看起来应该像这样(从演示应用程序源复制):

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>不添加方法参数.它添加了请求参数.

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

可以从 http://anonsvn.jboss.org/repos/richfaces/tags/3.3.1.GA/samples/richfaces-demo

这篇关于RF演示中的RichFaces rich:panelMenu导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 03:57