开发者

Target Unreachable, returned null [duplicate]

开发者 https://www.devze.com 2023-04-03 08:59 出处:网络
This question already has answers here: Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable
This question already has answers here: Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable (18 answers) Closed 7 years ago.

i'm experiencing problems while trying to use the object currentActeurObjetProjet and display its attributes on a dialog using Primefaces but it keeps showing this error:

ATTENTION: /infoprojet.xhtml @493,159 value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.nomObjet}": Target Unreachable, 'objets' returned null javax.el.PropertyNotFoundException: /infoprojet.xhtml @493,159 value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.nomObjet}": Target Unreachable, 'objets' returned null开发者_高级运维

here is the back up 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;
    } 
    .......
} 

here is my page code:

<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>

Regards


javax.el.PropertyNotFoundException: /infoprojet.xhtml @493,159 value="#{acteurObjetProjetBean.currentActeurObjetProjet.objets.nomObjet}": Target Unreachable, 'objets' returned null

EL is trying to tell you that it cannot set the nomObjet value because objets is null. EL won't autocreate any nested object properties for you. It will only autofill the leaf property. You just have to make sure that the objet property of the currentActeurObjetProject class is not null. You can do that by preparing it in for example the constructor of the ActeurObjetProjet class.

public ActeurObjetProjet() {
    this.objet = new Objet();
}

You can also do that in the constructor of ActeurObjetProjetBean instead.

private ActeurObjetProjet currentActeurObjetProject;

public ActeurObjetProjetBean() {
    this.currentActeurObjetProject = new ActeurObjetProjet();
    this.currentActeurObjetProject.setObject(new Object());
}

Choose whatever suits the functional/business requirements the best.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号