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 :

Déclenchement d'action JSF


Sujet :

JSF Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 1
    Par défaut Déclenchement d'action JSF
    Bonjour tout le monde,
    je suis débutante en jsf et j'essaie de faire un formulaire à l'aide de jsf et primefaces mais j'ai un problème car le bouton action ne déclenche pas l'action souhaitée ,voici le code :

    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
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
           xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
          xmlns:p="http://primefaces.org/ui">
        <h:head>
            <title>inscription</title>
     
        </h:head>
        <h:body>
            <p:layout style="min-width:400px;min-height:200px;" id="layout">  
        <p:layoutUnit position="west" resizable="true" size="100" minSize="40" maxSize="200">  
            Left  
        </p:layoutUnit> 
            <h:form id="form">  
     
        <p:growl id="growl" showDetail="true"/>  
      <p:layoutUnit position="center">
        <img src="images/logo.jpg" alt="logo"/>
        <h3>-espace Candidat-</h3>
        <p:panel header="Inscription Candidat" footer="recommandations inscription">  
           <h:outputText value="les champs mentionnées par * doivent etre remplis pour accomplir votre
                         inscription. Merci !!" />  
     
           <center>
            <p:panelGrid columns="2">  
        <f:facet name="header">  
         Inscrivez vous 
        </f:facet>  
     
        <p:outputLabel for="nom" value="Nom: *" />  
        <p:inputText id="nom" value="#{imaneBean.nomCandidat}" label="Nom" /> 
     
     
     
     
        <f:facet name="footer">  
            <p:commandButton  id="saveButton" type="button" value="save" icon="ui-icon-disk" style="margin:0" action="#{imaneBean.insert()}"/>
            <p:commandButton type="button" value="exit" icon="ui-icon-circle-close" style="margin:0"/>
     
        </f:facet>  
    </p:panelGrid>  
           </center>
        </p:panel>
        </p:layoutUnit>  
     
     
            </h:form>
     
    </p:layout>  
     
        </h:body>
    </html>
    et le bean :
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package Bean;
    import DAO.connexionBD;
    import java.io.Serializable;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.Date;
    import java.sql.Statement;
    import java.util.logging.Level;
    import java.util.logging.Logger;
     
    /**
     *
     * @author hp
     */
    public class imaneBean implements Serializable{
     
        private String nomCandidat;
     
        private String prenomCandidat;
     
        private Character sexe;
     
     
     
        private Date dateNaissance;
     
        private String type;
     
        private String mail;
     
        private String adresse;
     
        public String getNomCandidat() {
            return this.nomCandidat;
        }
     
        public void setNomCandidat(String nomCandidat) {
            this.nomCandidat = nomCandidat;
        }
     
        public String getPrenomCandidat() {
            return prenomCandidat;
        }
     
        public void setPrenomCandidat(String prenomCandidat) {
            this.prenomCandidat = prenomCandidat;
        }
     
        public Character getSexe() {
            return sexe;
        }
     
        public void setSexe(Character sexe) {
            this.sexe = sexe;
        }
     
     
     
        public Date getDateNaissance() {
            return dateNaissance;
        }
     
        public void setDateNaissance(Date dateNaissance) {
            this.dateNaissance = dateNaissance;
        }
     
        public String getType() {
            return type;
        }
     
        public void setType(String type) {
            this.type = type;
        }
     
        public String getMail() {
            return mail;
        }
     
        public void setMail(String mail) {
            this.mail = mail;
        }
     
        public String getAdresse() {
            return adresse;
        }
     
        public void setAdresse(String adresse) {
            this.adresse = adresse;
        }
     
     
        public void insert(){
     
     
            int val = 0; 
     
            try 
    { 
     
     
     
    Class.forName("com.mysql.jdbc.Driver"); 
    System.out.println ("driver etablie"); 
    } 
    catch(Exception e) 
    { 
    System.out.println ("erreur:Driver int" + 
    "rouvable"); 
    } 
     
     
    try { 
     
        String URL = "jdbc:mysql://localhost:3306/concours"; 
    String USER = "root"; 
    String PASSWD = "ensias"; 
     Connection con=null;
     
    con =DriverManager.getConnection(URL,USER, PASSWD);
       //DAO.connexionBD c=new connexionBD();
       //c.connexion();
     
       //Connection con=null;
     
          Statement st;
    st = con.createStatement();
     
    val = st.executeUpdate("INSERT INTO `user` (`login`) VALUES('"+nomCandidat+"')");
    //
    System.out.append("insertionaccomplie");
    } catch (SQLException ex) { 
    Logger.getLogger(connexionBD.class.getName()).log(Level.SEVERE, null, ex); 
    } 
     
    System.out.println(val); 
     
        }
        /**
         * icon="ui-icon-disk" style="margin:0"
         * Creates a new instance of imaneBean
         */
        public imaneBean() {
            nomCandidat="";
        }
    }
    merci pour votre aide

  2. #2
    Membre éclairé Avatar de liquideshark
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Septembre 2006
    Messages
    347
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Service public

    Informations forums :
    Inscription : Septembre 2006
    Messages : 347
    Par défaut
    Etudiant de l'Ensias . Quel serveur d'application utilise tu ? post l'erreur imprimé par le log de ton serveur.

    rapidement si tu essaye
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <p:commandButton  id="saveButton" type="button" update=":form" value="save" icon="ui-icon-disk" style="margin:0" action="#{imaneBean.insert()}"/>
    else post your log

  3. #3
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    si cela ne marche pas essaies ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <p:commandButton  id="saveButton" type="button" value="save" icon="ui-icon-disk" style="margin:0" action="#{imaneBean.insert}">
      <f:ajax execute="@form" />
    </p:commandButton>
    Eric

  4. #4
    Membre confirmé Avatar de azassma
    Femme Profil pro
    Ph.D - Computer Vision
    Inscrit en
    Avril 2012
    Messages
    159
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ph.D - Computer Vision
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 159
    Par défaut
    essayez d'ajouter se code : avant la ligne nr 20
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    @ManagedBean
    @SessionScoped
    public class imaneBean implements Serializable{
    -
    -
    -
    -
    }

Discussions similaires

  1. [WD12E] déclenchement d'action sur checkbox
    Par biloux911 dans le forum WinDev
    Réponses: 4
    Dernier message: 09/11/2010, 11h24
  2. [JSF][Javascrit] Action JSF et Javascript
    Par mymyma dans le forum JSF
    Réponses: 3
    Dernier message: 14/09/2009, 13h28
  3. Appel d'action avec JSF
    Par et.rond.et.rond dans le forum JSF
    Réponses: 8
    Dernier message: 21/11/2006, 22h48
  4. comment retarder le déclenchement d'une action "onmouseover" ?
    Par Chris Cool dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 18/06/2006, 07h58

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