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

Frameworks Web Java Discussion :

Formulaire d'ajout :jsf


Sujet :

Frameworks Web Java

  1. #1
    Membre à l'essai
    Inscrit en
    Mars 2009
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 13
    Points : 12
    Points
    12
    Par défaut Formulaire d'ajout :jsf
    Je suis en train de faire une formulaire d'ajout client:
    partie métier:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    @PersistenceContext(unitName="partieEjb")
        EntityManager em;
         public Clients ajoutClients(Clients c)
        {
            em.persist(c);
            return c;
        }

  2. #2
    Membre à l'essai
    Inscrit en
    Mars 2009
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 13
    Points : 12
    Points
    12
    Par défaut la partie web
    managedbens:
    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
    55
    56
    57
    58
     
    package test;
     
    import javax.ejb.EJB;
     
    import presentation.Clients;
     
    import service.GestionClientsLocal;
     
     
     
    public class AccountContoller {
        @EJB
        private GestionClientsLocal customerbean;
        private Clients cl=new Clients();
        private int id;
        private String nom;
        private String prenom;
        public String docreateClients(){
            cl=customerbean.ajoutClients(cl);
            return "cl";          
        }
        public  AccountContoller (){
     
        }
        public GestionClientsLocal getCustomerbean() {
            return customerbean;
        }
        public void setCustomerbean(GestionClientsLocal customerbean) {
            this.customerbean = customerbean;
        }
        public Clients getCl() {
            return cl;
        }
        public void setCl(Clients cl) {
            this.cl = cl;
        }
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public String getNom() {
            return nom;
        }
        public void setNom(String nom) {
            this.nom = nom;
        }
        public String getPrenom() {
            return prenom;
        }
        public void setPrenom(String prenom) {
            this.prenom = prenom;
        }
     
     
    }

  3. #3
    Membre à l'essai
    Inscrit en
    Mars 2009
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 13
    Points : 12
    Points
    12
    Par défaut partie jsp
    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
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:messages></h:messages>
    <h:panelGrid columns="2"
    columnClasses="rightAlign,leftAlign">
    <h:outputText value="Identifiant:">
    </h:outputText>
    <h:inputText label="Identifiant"
    value="#{accountContoller.id}"
    required="true">
    </h:inputText>
    <h:outputText value="Nom:"></h:outputText>
    <h:inputText label="Nom"
    value="#{accountContoller.nom}"
    required="true">
    <f:validateLength minimum="2"
    maximum="30"></f:validateLength>
    </h:inputText>
    <h:outputText value="Prenom:">
    </h:outputText>
    <h:inputText label="Prenom" value="#{accountContoller.prenom}">
    <f:validateLength minimum="3"
    maximum="30"></f:validateLength>
    </h:inputText>
    <h:panelGroup></h:panelGroup>
    <h:commandButton value="Create Client"
    action="#{accountContoller.docreateClients}" type="submit"></h:commandButton>
    </h:panelGrid>
    </h:form>
    </f:view>
    </body>
    </html>

  4. #4
    Membre à l'essai
    Inscrit en
    Mars 2009
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 13
    Points : 12
    Points
    12
    Par défaut prbléme
    Quand je fait l'exécution la formualire est affiché mais quand je clic sur le bouton "ajout"il ya une message d'erreur quii est affiché:

    description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
    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
    55
    56
    57
    58
     
    exception 
     
    javax.servlet.ServletException: #{accountContoller.docreateClients}: java.lang.NullPointerException
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
        org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
     
     
    cause mère 
     
    javax.faces.FacesException: #{accountContoller.docreateClients}: java.lang.NullPointerException
        com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
        javax.faces.component.UICommand.broadcast(UICommand.java:383)
        javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
        javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
        com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
        com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
        org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
     
     
    cause mère 
     
    javax.faces.el.EvaluationException: java.lang.NullPointerException
        javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
        com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
        javax.faces.component.UICommand.broadcast(UICommand.java:383)
        javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
        javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
        com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
        com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
        org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
     
     
    cause mère 
     
    java.lang.NullPointerException
        test.AccountContoller.docreateClients(AccountContoller.java:19)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:585)
        org.apache.el.parser.AstValue.invoke(AstValue.java:131)
        org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
        org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
        javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
        com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
        javax.faces.component.UICommand.broadcast(UICommand.java:383)
        javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
        javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
        com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
        com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
        org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

  5. #5
    Membre à l'essai
    Inscrit en
    Mars 2009
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 13
    Points : 12
    Points
    12
    Par défaut Quel est la solution
    Merci beaucoup pour votre aide

Discussions similaires

  1. [MySQL] Formulaire et ajout dans la base
    Par MacSIM dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 05/04/2007, 23h02
  2. Réponses: 2
    Dernier message: 22/03/2007, 22h55
  3. [sous formulaire indépendant] Ajout d'une ligne
    Par stéphane_ais2 dans le forum IHM
    Réponses: 7
    Dernier message: 15/02/2007, 12h19
  4. [Formulaire] Comment ajouter des données .
    Par maya00 dans le forum IHM
    Réponses: 1
    Dernier message: 05/10/2006, 11h14
  5. ouvrerture formulaire d'ajout de données
    Par toinekikil dans le forum Access
    Réponses: 5
    Dernier message: 10/08/2006, 14h58

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