IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JSF Java Discussion :

Problème avec UPDATE EJB + JSF


Sujet :

JSF Java

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 21
    Points : 18
    Points
    18
    Par défaut Problème avec UPDATE EJB + JSF
    Bonjour,

    donc j'ai un tableau ou je recupère une liste de produit

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
       <h:form>
                        <h:dataTable value="#{MaterielApp.materiel}"
                                     var="materiel"
                                     border="1">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Nom"/>
                                </f:facet>
     
                                <h:outputText value="#{materiel.nomProduit}"/>
                            </h:column>
     
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Description"/>
                                </f:facet>
                                    <h:outputText value="#{materiel.descriptionProduit}"/>
     
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Emballage"/>
                                </f:facet>
                                    <h:outputText value="#{materiel.emballage}"/>
     
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Emballage"/>
                                </f:facet>
                                    <h:outputText value="#{materiel.stockProduit}"/>
     
                            </h:column>
                             <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Prix"/>
                                </f:facet>
                                    <h:outputText value="#{materiel.coutProduit}"/>
     
                            </h:column>
                            <h:column>
                                <h:commandLink value="Remove" action="#{MaterielRemover.removeProduit}">
        <f:setPropertyActionListener target="#{MaterielRemover.idMateriel}" value="#{materiel.idMateriel}" />
    </h:commandLink>
                            </h:column>
                                                    <h:column>
      <h:commandLink value="Edit" action="editProduit">
     
         <f:setPropertyActionListener target="#{MaterielEdit.idMateriel}" value="#{materiel.idMateriel}" />
                                </h:commandLink>
                            </h:column>
                        </h:dataTable>
     
                    </h:form>
    Voici ma classe materielEdit

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    public class MaterielEdit {
     
        private Materiel materiel;
     
        @EJB
        private MaterielService materielService;
     
        private int idMateriel;
     
        public int getIdMateriel() {
            return idMateriel;
        }
     
        public void setIdMateriel(int idMateriel) {
            this.idMateriel = idMateriel;
        }
     
        public MaterielService getMaterielService() {
            return materielService;
        }
     
        public void setMaterielService(MaterielService materielService) {
            this.materielService = materielService;
        }
     
        public String updateProduit(){
     
      getMaterielService().updateMateriel(getMateriel());
        return "listProduitAdmin";
      }
     
          public Materiel getMateriel() {
          System.out.println(">>>>>>>>>>>>>>>>" + getMaterielService().getMateriel(idMateriel));
          materiel = getMaterielService().getMateriel(idMateriel);
            return materiel;
        }
     
        public void setMateriel(Materiel materiel) {
            this.materiel = materiel;
        }
    quand je clique sur EDIT j'ai bien mon formulaire avec tous les renseignement du produit

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
               <h:form>
               <h:outputText
                        value="Edition of Produit"/>
                <h:panelGrid columns="3">
     
                    <h:outputLabel for="name" value="Name:"/>
                    <h:inputText id="name" value="#{MaterielEdit.materiel.nomProduit}"
                                 required="true"/>
                    <h:message for="name" style="color: red"/>
     
     
                    <h:outputLabel for="prix" value="prix : "/>
                    <h:inputText id="url" value="#{MaterielEdit.materiel.coutProduit}"
                                 size="50"
                                 required="true"/>
                    <h:message for="prix"/>
     
     
                    <h:outputLabel for="stock" value="Stock :"/>
                    <h:inputText id="language"
                                 value="#{MaterielEdit.materiel.stockProduit}"/>
                    <h:message for="stock"/>
     
                    <h:outputLabel for="description" value="Description:"/>
                    <h:inputText id="description"
                                 value="#{MaterielEdit.materiel.descriptionProduit}"
                                 required="true"/>
                    <h:message for="description"/>
                   <h:outputLabel for="id" value="Description:"/>
                   <h:inputText id="id"
                                 value="#{MaterielEdit.materiel.idMateriel}"
                                 />
                </h:panelGrid>
                <br/>
                <br/>
     <h:commandButton value="Update" action="#{MaterielEdit.updateProduit}">
      <f:setPropertyActionListener target="#{MaterielEdit.idMateriel}" value="#{materiel.idMateriel}" />
       </h:commandButton>
            </h:form>
    Mais quand je clique sur le bouton UPDATE iva sur MaterielEdit.updateProduit pour mettre a jour mais j'ai cette erreur qui apparait :

    type Exception report
    message
    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: /EditMateriel.xhtml @32,47 value="#{MaterielEdit.materiel.nomProduit}": Target Unreachable, 'materiel' returned null
    root cause
    javax.el.PropertyNotFoundException: /EditMateriel.xhtml @32,47 value="#{MaterielEdit.materiel.nomProduit}": Target Unreachable, 'materiel' returned null
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_01 logs.


    Merci d'avance

  2. #2
    Membre confirmé Avatar de heid
    Profil pro
    Inscrit en
    Mai 2002
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France, Indre et Loire (Centre)

    Informations forums :
    Inscription : Mai 2002
    Messages : 388
    Points : 597
    Points
    597
    Par défaut
    Il semble qu'il ne fasse pas le binding entre tes composant et la valeur dans ton back bean (materiel) :il retourne null.

    Ajoutes un h:messages pour voir si il te renvoi une erreur quelconque.
    Sinon utilises un composant du type faces tace pour voir si ta requête JSF est correctement traitée (ex : errs de validations).

    ton problème na rien a voir avec les EJBS, tu peux essayer de récpérer simplement getMateriel() dans updateProduit, il sera null.

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 21
    Points : 18
    Points
    18
    Par défaut
    J'ai mis un <h:messages> et il me renvoye rien mais j'arrive pas a savoir pourquoi materiel est null allors que les données apparaise sur la page ou il y a le lien update.

  4. #4
    Expert éminent
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Points : 7 679
    Points
    7 679
    Par défaut
    Bonjour,
    Cette instruction:
    System.out.println(">>>>>>>>>>>>>>>>" + getMaterielService().getMateriel(idMateriel));
    Elle affiche quoi au runtime ?

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 21
    Points : 18
    Points
    18
    Par défaut
    Citation Envoyé par djo.mos Voir le message
    Bonjour,
    Cette instruction:
    System.out.println(">>>>>>>>>>>>>>>>" + getMaterielService().getMateriel(idMateriel));

    Elle affiche quoi au runtime ?
    Elle affiche >>>>>>>>>>>>>>>> NULL quand je clique sur update sinon quand je suis sur le tableau de produit et que je clique sur EDIT elle m'affiche
    le ID qui correspond bien a mon produit

  6. #6
    Expert éminent
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Points : 7 679
    Points
    7 679
    Par défaut
    T'es sur d'avoir mis ton managed bean (MaterielApp) en scope session ?

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 21
    Points : 18
    Points
    18
    Par défaut
    oui mon managed-bean MaterielApp est en session

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
        <managed-bean>
            <managed-bean-name>MaterielApp</managed-bean-name>
            <managed-bean-class>com.id54002.CaveAJP.app.MaterielApp</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
           <managed-bean>
            <managed-bean-name>MaterielRemover</managed-bean-name>
            <managed-bean-class>com.id54002.CaveAJP.app.MaterielRemove</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
            </managed-bean>
         <managed-bean>
            <managed-bean-name>MaterielEdit</managed-bean-name>
            <managed-bean-class>com.id54002.CaveAJP.app.MaterielEdit</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>

  8. #8
    Membre confirmé Avatar de heid
    Profil pro
    Inscrit en
    Mai 2002
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France, Indre et Loire (Centre)

    Informations forums :
    Inscription : Mai 2002
    Messages : 388
    Points : 597
    Points
    597
    Par défaut
    Maitre Yoda a dit :
    Faces trace tu te dois d'ajouter si la solution à ton problème tu souhaite trouver.

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 21
    Points : 18
    Points
    18
    Par défaut
    J'ai essayer mais c'est bizarre car il me met aucun message d'erreur et il va directement sur cette page avec sa

    /EditMateriel.xhtml @35,31 value="#{MaterielEdit.materiel.nomProduit}": Target Unreachable, 'materiel' returned null
    javax.el.PropertyNotFoundException: /EditMateriel.xhtml @35,31 value="#{MaterielEdit.materiel.nomProduit}": Target Unreachable, 'materiel' returned null

Discussions similaires

  1. Problème avec "update" du code ASP
    Par ocean_prince11 dans le forum ASP
    Réponses: 14
    Dernier message: 24/11/2006, 18h56
  2. problème avec update dans h:datatable
    Par rarrou dans le forum JSF
    Réponses: 1
    Dernier message: 03/11/2006, 15h22
  3. problème avec update
    Par chingo dans le forum Requêtes
    Réponses: 7
    Dernier message: 14/10/2006, 23h16
  4. [MySQL] Problème avec UPDATE
    Par oim dans le forum PHP & Base de données
    Réponses: 30
    Dernier message: 22/04/2006, 10h12
  5. [EJB2.1 Entity] [CMP] Problème avec les @ejb.finder
    Par karibouxe dans le forum Java EE
    Réponses: 20
    Dernier message: 28/12/2005, 23h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo