3

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

cascadox
  • 893
  • 4
  • 14
  • 32
  • 1
    It could either be that you are missing some getter/setter or your object (property) is not properly initialized. Are you sure that `objets` is properly initialized and has getter/setter in `ActeurObjetProjet`. – Bhesh Gurung Sep 06 '11 at 02:44

1 Answers1

11

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555