从JSF中的子类访问属性时,它失败并出现以下错误:
javax.el.PropertyNotFoundException: /grouptable/Create.xhtml @19,281 value="#{grouptableController.selected.grouptablePK.groupid}": Target Unreachable, 'null' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
at javax.faces.component.UIInput.validate(UIInput.java:934)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
at javax.faces.component.UIInput.processValidators(UIInput.java:691)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIForm.processValidators(UIForm.java:243)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:637)
以前有人见过这个吗?请帮忙。我正在使用glassfish v3。
答案 0 :(得分:2)
value="#{grouptableController.selected.grouptablePK.groupid}": Target Unreachable, 'null'
这基本上意味着其中一个嵌套属性为null
。在此上下文中,可以是返回null的selected
或grouptablePK
。只要JSF需要设置groupid
属性,它们就不应为null。
您需要自己预先实例化这些嵌套对象/ bean。 JSF / EL不会为你做那件事。
因此,而不是
public class ParentBean {
private ChildBean childBean;
}
你需要做
public class ParentBean {
private ChildBean childBean = new ChildBean();
}
或
public class ParentBean {
private ChildBean childBean;
public ParentBean() {
this.childBean = new ChildBean();
}
}
或者,如果ChildBean
也是托管bean,或者可以是托管bean,那么您还可以在faces-config.xml
中使用托管属性注入:
<managed-bean>
<managed-bean-name>parentBean</managed-bean-name>
<managed-bean-class>com.example.ParentBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>childBean</property-name>
<value>#{childBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>childBean</managed-bean-name>
<managed-bean-class>com.example.ChildBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
答案 1 :(得分:0)
如果您在解释错误时遇到困难,那么在您的facelets页面上,它无法理解您的意思:
#{grouptableController.selected.grouptablePK.groupid}
希望这有帮助。