【发布时间】:2012-05-28 06:15:38
【问题描述】:
我希望根据下拉列表项的选择来检索列表。为此,我正在使用以下不起作用的代码:
<p:selectOneMenu style="width: 150px" value="#{watchBean.exchange}">
<f:selectItem itemLabel="NSE" itemValue="nse"/>
<f:selectItem itemLabel="BSE" itemValue="bse"/>
<p:ajax event="change" update=":frm" listener="#{watchBean.doScripList}" />
</p:selectOneMenu>
豆码:
public void doScripList(ValueChangeEvent e)
{
sl=getAllScripByExchange((String)e.getNewValue()); //sl is of type List<MasterScrip>
}
当我调试时,我看到事件没有被触发并且我得到以下错误:
javax.el.MethodNotFoundException: Method not found: beans.watchBean@9ac2e4.doScripList(javax.faces.event.AjaxBehaviorEvent)
at com.sun.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:155)...
当我省略 p:ajax 时,'exchange' 类型也不是 get/set 是什么导致了这个问题?它的解决方案是什么?
已编辑 将方法重命名为 wow() 仍然是同样的错误:
javax.el.MethodNotFoundException: Method not found: beans.watchBean@1732d83.wow(javax.faces.event.AjaxBehaviorEvent)
已编辑:托管 bean 代码
import java.util.List;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.ws.WebServiceRef;
import service.MasterScrip;
import service.StatelessWebService_Service;
@Named(value = "watchBean")
@RequestScoped
public class watchBean {
@WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/StatelessWebService/StatelessWebService.wsdl")
private StatelessWebService_Service service;
/** Creates a new instance of watchBean */
public watchBean() {
}
String uname,scripSym,exchange;
Integer scripID;
List<UserTrack> ut;
List<MasterScrip> sl;
public List<MasterScrip> getSl() {
return sl;
}
public void setSl(List<MasterScrip> sl) {
this.sl = sl;
}
public String getExchange() {
return exchange;
}
public void setExchange(String exchange) {
sl=getAllScripByExchange(exchange);
this.exchange = exchange;
}
public void wow(ValueChangeEvent e)
{
sl=getAllScripByExchange((String)e.getNewValue());
// setSl(sl);
//FacesContext.getCurrentInstance().renderResponse();
// sl=getAllScripByExchange(exchange);
}
【问题讨论】:
-
进行完整性检查:尝试将您的
doScripList重命名为wow并尝试使用<p:ajax listener="#{watchBean.wow}"...。(重新启动您的网络服务器...) -
您可以看到@Sai Ye Yan Naing Aye 下面给出的答案,它说它是 primefaces 3.2 中的一个错误。是真的吗?还是我应该选择你的解决方案?
-
如果没有打开问题的链接,我不会指望“它是一个错误”+他给出的解决方案来自 JSF 1...
-
将方法重命名为 wow() 还是一样的错误:javax.el.MethodNotFoundException: Method not found: beans.watchBean@1732d83.wow(javax.faces.event.AjaxBehaviorEvent)
-
检查你的进口,像这样的东西?
import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped;
标签: java jakarta-ee primefaces