目标无法访问,返回null

cas*_*dox 3 java-ee primefaces jsf-2

我在尝试使用对象currentActeurObjetProjet时遇到问题,并使用Primefaces在对话框中显示其属性,但它一直显示此错误:

注意:/infoprojet.xhtml @ 493159值= "#{} acteurObjetProjetBean.currentActeurObjetProjet.objets.nomObjet":目标不可达, 'OBJETS' 返回null javax.el.PropertyNotFoundException:/infoprojet.xhtml @ 493159值="#{acteurObjetProjetBean. currentActeurObjetProjet.objets.nomObjet}":目标无法访问,'objets'返回null

这是备份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;
    } 
    .......
} 
Run Code Online (Sandbox Code Playgroud)

这是我的页面代码:

<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>
Run Code Online (Sandbox Code Playgroud)

问候

Bal*_*usC 11

javax.el.PropertyNotFoundException:/infoprojet.xhtml @ 493,159 value ="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.nomObjet}":目标无法访问,'objets'返回null

EL是想告诉你,它不能设置nomObjet值,因为objetsnull.EL不会为您自动创建任何嵌套对象属性.它只会自动填充叶属性.您只需要确保该类的objet属性currentActeurObjetProject不是null.你可以通过在例如ActeurObjetProjet类的构造函数中准备它来做到这一点.

public ActeurObjetProjet() {
    this.objet = new Objet();
}
Run Code Online (Sandbox Code Playgroud)

您也可以在构造函数中执行此操作ActeurObjetProjetBean.

private ActeurObjetProjet currentActeurObjetProject;

public ActeurObjetProjetBean() {
    this.currentActeurObjetProject = new ActeurObjetProjet();
    this.currentActeurObjetProject.setObject(new Object());
}
Run Code Online (Sandbox Code Playgroud)

选择最适合功能/业务要求的产品.