Jakarta ee 无法访问目标,返回null
尝试使用对象currentActeurObjetProjet并使用Primefaces在对话框上显示其属性时遇到问题,但它始终显示此错误:Jakarta ee 无法访问目标,返回null,jakarta-ee,jsf-2,primefaces,Jakarta Ee,Jsf 2,Primefaces,尝试使用对象currentActeurObjetProjet并使用Primefaces在对话框上显示其属性时遇到问题,但它始终显示此错误: 注意:/infoprojet.xhtml@493159 value=“#{ACTEUROBJETPROJET.currentActeurObjetProjet.objets.nomObjet}”:无法访问目标,“objets”返回空值 javax.el.PropertyNotFoundException:/infoprojet.xhtml@493159 va
注意:/infoprojet.xhtml@493159 value=“#{ACTEUROBJETPROJET.currentActeurObjetProjet.objets.nomObjet}”:无法访问目标,“objets”返回空值 javax.el.PropertyNotFoundException:/infoprojet.xhtml@493159 value=“#{acteurObjetProjetBean.currentActeurObjetProjet.ObjJets.nomObjet}”:无法访问目标,“ObjJets”返回空值 下面是备份bean:
package com.mycompany.projet;
.......
/**
*
* @author Omar
*/
@Component("etatsBean")
@Scope("session")
public class ActeurObjetProjetBean implements Serializable{
.......
private ActeurObjetProjet currentActeurObjetProjet=new ActeurObjetProjet();
.......
////////////////////////////////////////////////////////// Méthodes & fonctions\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////////////////////////////////////////// setters & getters \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public void setCurrentActeurObjetProjet(ActeurObjetProjet currentActeurObjetProjet)
{
this.currentActeurObjetProjet=currentActeurObjetProjet;
}
public ActeurObjetProjet getCurrentActeurObjetProjet()
{
return currentActeurObjetProjet;
}
.......
}
这是我的页面代码:
<p:dialog header="Editer Objet" widgetVar="editobjetDialog" resizable="true" width="300" height="300" showEffect="clip" hideEffect="clip" modal="true">
<p:outputPanel id="editobjetDetail" style="text-align:center;" layout="block">
<center>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel value="Nom Objet "/>
<p:inputText value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.nomObjet}" style="width: 180px"/>
<h:outputLabel value="Accès DB2 "/>
<p:inputText value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.accesDb2}" style="width: 180px"/>
<h:outputLabel value="Etat "/>
<p:inputText value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.etatObjet}" style="width: 180px"/>
<h:outputLabel value="Version "/>
<p:inputText value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.versionObjet}" style="width: 180px"/>
</h:panelGrid>
</center>
</p:outputPanel>
</p:dialog>
问候
javax.el.PropertyNotFoundException:/infoprojet.xhtml@493159 value=“#{acteurObjetProjetBean.currentActeurObjetProjet.ObjJets.nomObjet}”:无法访问目标,“ObjJets”返回空值
EL试图告诉您它无法设置nomObjet
值,因为objet
为null
。EL不会为您自动创建任何嵌套对象属性。它只会自动填充叶属性。您只需确保currentActeurObjetProject
类的objet
属性不是null
。您可以通过在ActeurObjetProjet
类的构造函数中准备它来实现这一点
public ActeurObjetProjet() {
this.objet = new Objet();
}
您也可以在ActeurObjetProjetBean
的构造函数中执行此操作
private ActeurObjetProjet currentActeurObjetProject;
public ActeurObjetProjetBean() {
this.currentActeurObjetProject = new ActeurObjetProjet();
this.currentActeurObjetProject.setObject(new Object());
}
选择最适合功能/业务需求的对象。可能是缺少某些getter/setter,或者对象(属性)未正确初始化。您确定
objets
已正确初始化,并且在ActeurObjetProjet
中具有getter/setter吗。