我有一个级联下拉菜单,它在一个系统上运行良好,但在另一个系统上无法运行。请参考以下代码: xhtml:
<p:selectOneMenu style="width: 150px" value="#{reportBean.exchange}">
<f:selectItem itemLabel="NSE" itemValue="nse"/>
<f:selectItem itemLabel="BSE" itemValue="bse"/>
<p:ajax update="sym" listener="#{reportBean.wow()}"/>
</p:selectOneMenu>
<h:outputText value="Scrip Symbol :"/>
<p:selectOneMenu value="#{reportBean.scripID}" id="sym" style="width: 100px">
<f:selectItem itemLabel="All" itemValue="0"/>
<f:selectItems var="scrip" value="#{reportBean.sl}" itemLabel="#{scrip.scripSymbol}" itemValue="#{scrip.scripID}"/>
</p:selectOneMenu>
wow() 方法没有被调用,下面是 bean 代码:
@javax.faces.bean.ManagedBean
@javax.faces.bean.ViewScoped
public class reportBean implements Serializable {
@WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/StatelessWebService/StatelessWebService.wsdl")
transient private StatelessWebService_Service service ;
private java.util.List<service.MasterScrip> getAllScripByExchange(java.lang.String exchange) {
service.StatelessWebService port = service.getStatelessWebServicePort();
return port.getAllScripByExchange(exchange);
}
public void wow()
{
sl=getAllScripByExchange(exchange);
}
我调试了一下,发现调试点来了就行了
service.StatelessWebService port = service.getStatelessWebServicePort();
并进入 InvocationTargetException.java 并进入以下方法:
public InvocationTargetException(Throwable target) {
super((Throwable)null); // Disallow initCause
this.target = target;
}
最后在 glassfish 中返回的错误是:
WARNING: /ClientTemplate/tradeReport.xhtml @17,74 listener="#{reportBean.wow()}": java.lang.NullPointerException
javax.el.ELException: /ClientTemplate/tradeReport.xhtml @17,74 listener="#{reportBean.wow()}": java.lang.NullPointerException
在 managd bean 中,如果我没有实现可序列化或者我没有将服务设为瞬态,那么我会得到 NotSerializable 异常。这个错误的原因是什么?我该如何解决? 编辑:
服务豆:
@ManagedBean
@javax.faces.bean.RequestScoped
public class serviceBean{
@WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/StatelessWebService/StatelessWebService.wsdl")
private StatelessWebService_Service service;
@ManagedProperty("#{reportBean}")
private reportBean reportBean;
public beans.reportBean getReportBean() {
return reportBean;
}
public void setReportBean(beans.reportBean reportBean) {
this.reportBean = reportBean;
} //other props
public String getExchange() {
return exchange;
}
public void setExchange(String exchange) {
this.exchange = exchange;
}
public void wow()
{
reportBean.setSl(getAllScripByExchange(reportBean.getExchange()));
}
报告豆:
@javax.faces.bean.ManagedBean
@javax.faces.bean.ViewScoped
public class reportBean implements Serializable {
private Integer scripID;
private String exchange;
private List<service.TradeStock> tradeList;
private List<MasterScrip> sl; //get set
现在我收到以下错误:
SEVERE: Error Rendering View[/ClientTemplate/tradeReport.xhtml]
javax.faces.FacesException: java.io.NotSerializableException: service.MasterScrip