2010-02-25 33 views
1

我已經在index.jsp頁面中逐字地獲得了RichFaces演示panelMenu source。因爲演示不提供任何輔助bean代碼來支持這個源,我在panelMenu.java創建這些方法:RichFaces rich:來自RF演示的panelMenu導致錯誤

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: [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)

回答

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

+0

@馬克劉易斯檢查我的更新 – Bozho 2010-02-25 15:29:00

+0

@Bozho - 你可以給我到源的確切的鏈接? setCurrent方法也需要複製。 – volvox 2010-02-25 15:32:31

+0

@Bozho,我不明白你的答案中引用'f:param'的部分。它有什麼關係? – volvox 2010-02-25 15:35:27