1

在 SelectOneMenu 组件中使用 ValueChangeListener 时遇到错误。我不确定是由于导致此问题的方法还是因为 xhtml 找不到该方法。

错误

12:54:10,815 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http--127.0.0.1-8080-7) JSF1073: javax.faces.event.AbortProcessingException caught during processing of APPLY_REQUEST_VALUES 2 : UIComponent-ClientId=j_idt6:j_idt18, Message=/reportPage.xhtml @48,185 valueChangeListener="#{statusReport.retrieveReport}": java.lang.NullPointerException
12:54:10,818 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http--127.0.0.1-8080-7) /reportPage.xhtml @48,185 valueChangeListener="#{statusReport.retrieveReport}": java.lang.NullPointerException: javax.faces.event.AbortProcessingException: /reportPage.xhtml @48,185 valueChangeListener="#{statusReport.retrieveReport}": java.lang.NullPointerException
    at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(MethodExpressionValueChangeListener.java:157) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at javax.faces.event.ValueChangeEvent.processListener(ValueChangeEvent.java:134) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:759) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:935) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_25]
Caused by: java.lang.NullPointerException
    at com.weeklyreport.bean.StatusReport.retrieveReport(StatusReport.java:163) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.6.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.6.0_25]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.6.0_25]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.10.Final.jar:]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.10.Final.jar:]
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(MethodExpressionValueChangeListener.java:144) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    ... 22 more

xhtml代码

<ice:panelGroup
                style="border: 1px solid black; background-color: #F0ECEB;padding: 10px; text-align: left;height=20pix;">
                <ice:selectOneMenu value="#{statusReport.projectDetID}" valueChangeListener="#{statusReport.retrieveReport}" onchange="this.form.submit()"  immediate="true" style="width: 150px;" > 
                    <f:selectItem itemLabel="Select One" itemValue="" />
                    <f:selectItems value="#{statusReport.listOfProjectDetail}"
                        var="projectDetail" itemLabel="#{projectDetail.project}              #{projectDetail.startDate}   -    #{projectDetail.endDate}"
                        itemValue="#{projectDetail.pdetailId}" />
                </ice:selectOneMenu>

            </ice:panelGroup>

豆码

public void retrieveReport(ValueChangeEvent event){

    System.out.println(" Processing ...code..");
    @SuppressWarnings({ "unchecked", "unused" })
    List<ProjectDetail> listOfProjectDet1 = (List<ProjectDetail>) projectDetailFacade.find(projectDetID);
    System.out.println("project details size" + listOfProjectDet1.size());
    System.out.println("Generated Data:Completed");

}

如何解决?

4

1 回答 1

0

以下任何一项为空

1 ->projectDetailFacade为空

List<ProjectDetail> listOfProjectDet1 = (List<ProjectDetail>) projectDetailFacade.find(projectDetID); 

2 - >listOfProjectDet1为空

System.out.println("project details size" + listOfProjectDet1.size());

检查哪个为空,修复应该可以解决您的问题。

于 2012-06-10T17:07:54.693 回答