Salut à tous, c'est la première fois que je poste dans ce forum alors dsl si j'ai fait une gaffe concernant le sujet et tt ça;
Alors mon problème c'est que je débute avec le développement web avec java et suis entrain de développer une application avec JSF, Spring, Hibernate et Tomcat et un SGBD PostgreSql et j'ai un problème c'est que les valeurs que je saisi sont toujours nulles ce qui cré des lignes vierges dans la BD sauf pour l'Id qui est généré automatiquement je vous poste mon bean et ma page jsp mon faces-config.xml ainsi que mon applicationContext.xml
merci de votre aide
EmployeBean.java
Code java : 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 package com.sungard.beans; import com.sungard.persistence.Employe; import com.sungard.service.IEmployeService; public class EmployeBean { //private String empId; Employe employe; private String nom; private String prenom; private String date_embauche; private float salaire; private String fonction; private IEmployeService empServ; public EmployeBean() { } public String addEmployeAction(){ try{ employe=new Employe(); employe.setNom(nom); System.out.println(nom); employe.setPrenom(prenom); System.out.println(prenom); employe.setDate_embauche(date_embauche); System.out.println(date_embauche); employe.setSalaire(salaire); System.out.println(salaire); employe.setFonction(fonction); System.out.println(fonction); this.empServ.addEmploye(employe); return "success"; }catch(Exception e){ e.printStackTrace(); return "failure"; } } public String deleteEmployeAction(){ try{ this.empServ.deleteEmploye(this.employe); return "success"; }catch(Exception e){ e.printStackTrace(); return "failure"; } } public void setEmpServ(IEmployeService empServ) { this.empServ = empServ; } /*public String getEmpId() { return empId;*/ 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; } public String getDate_embauche() { return date_embauche; } public void setDate_embauche(String date_embauche) { this.date_embauche = date_embauche; } public float getSalaire() { return salaire; } public void setSalaire(float salaire) { this.salaire = salaire; } public String getFonction() { return fonction; } public void setFonction(String fonction) { this.fonction = fonction; } public IEmployeService getEmpServ() { return empServ; } } /*public void setEmpId(String empId) { this.empId = empId; if(empId!=null && !empId.equals("")){ Integer id=new Integer(empId); try{ if(empServ!=null){ empServ.getEmployeById(id); } } catch(Exception e){ e.printStackTrace(); } } }*/mon faces-config.xml
Code html : 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 <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%><%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%><%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!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 style="height: 148px"> <h1>Bienvenue à l'interface ajouter un employé</h1> <h3>Veuillez remplir soigneusement tous les champs.</h3> </h:form> <h:panelGrid border="1" columns="2" style="width: 516px; height: 241px"> <h:outputText value="NCIN"></h:outputText> <h:form> <h:inputText style="width: 248px; height: 24px"></h:inputText> </h:form> <h:outputText value="Nom"></h:outputText> <h:inputText id="nom" value="#{employeBean.nom}" style="width: 246px; height: 24px"></h:inputText> <h:outputText value="Prenom"></h:outputText> <h:inputText id="prenom" value="#{employeBean.prenom}" style="width: 245px; height: 29px"></h:inputText> <h:outputText value="Date d'embauche"></h:outputText> <h:inputText id="date" value="#{employeBean.date_embauche}" style="width: 246px; height: 29px"></h:inputText> <h:outputText value="Salaire"></h:outputText> <h:inputText id="salaire" value="#{employeBean.salaire}" style="width: 247px; height: 29px"></h:inputText> <h:outputText value="Fonction"></h:outputText> <h:inputText id="fonction" value="#{employeBean.fonction}" style="width: 247px; height: 29px"></h:inputText> </h:panelGrid> <h:panelGrid border="1" columns="1" style="height: 22px; width: 516px"> <h:form> <h:commandButton value="ADD" action="#{employeBean.addEmployeAction}" style="width: 505px" /> </h:form> </h:panelGrid> </f:view> </body> </html>
Code xml : 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 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config> <managed-bean> <managed-bean-name>menu</managed-bean-name> <managed-bean-class>com.sungard.beans.Menu</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <managed-bean> <managed-bean-name>employeBean</managed-bean-name> <managed-bean-class> com.sungard.beans.EmployeBean </managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>empServ</property-name> <property-class> com.sungard.service.IEmployeService </property-class> <value>#{empServ}</value> </managed-property> </managed-bean> <navigation-rule> <display-name>Interface Principale</display-name> <from-view-id>/faces/Interface Principale.jsp</from-view-id> <navigation-case> <from-outcome>JETON_CREATE</from-outcome> <to-view-id>/faces/AjoutEmploye.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>Interface Principale</display-name> <from-view-id>/faces/Interface Principale.jsp</from-view-id> <navigation-case> <from-outcome>JETON_FIND</from-outcome> <to-view-id>/faces/RechercheEmploye.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>AjoutEmploye</display-name> <from-view-id>/faces/AjoutEmploye.jsp</from-view-id> <navigation-case> <from-outcome>failure</from-outcome> <to-view-id>/faces/Failure.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>AjoutEmploye</display-name> <from-view-id>/faces/AjoutEmploye.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/faces/Success.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>RechercheEmploye</display-name> <from-view-id>/faces/RechercheEmploye.jsp</from-view-id> <navigation-case> <from-outcome>failure</from-outcome> <to-view-id>/faces/Failure.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>RechercheEmploye</display-name> <from-view-id>/faces/RechercheEmploye.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/faces/Success.jsp</to-view-id> </navigation-case> </navigation-rule> <application> <variable-resolver> org.springframework.web.jsf.DelegatingVariableResolver </variable-resolver> <locale-config /> </application> </faces-config>et enfin les resultats
Code xml : 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 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- ====================== Configuration de la persistence =============================--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>org.postgresql.Driver</value> </property> <property name="url"> <value> jdbc:postgresql://172.16.60.163:5432/TravelManagementDB </value> </property> <property name="username"> <value>Traveler</value> </property> <property name="password"> <value>Traveler</value> </property> </bean> <!-- ========================Hibernate Session Factory==================== --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="annotatedClasses"> <list> <value>com.sungard.persistence.Employe</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.PostgreSQLDialect </prop> <prop key="hbm2ddl.auto">create</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.cglib.use_reflection_optimizer"> true </prop> <prop key="hibernate.cache.provider_class"> org.hibernate.cache.HashtableCacheProvider </prop> <prop key="hibernate.jdbc.batch_size">0</prop> </props> </property> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <!-- Spring Data Access Exception Translator Defintion --> <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <!-- Hibernate Template Defintion --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> <property name="jdbcExceptionTranslator"> <ref bean="jdbcExceptionTranslator" /> </property> </bean> <!-- Hibernate Transaction Manager Definition --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- ========================= Start of DAO DEFINITIONS ========================= --> <!-- Employe DAO Definition: Hibernate implementation --> <bean id="empDao" class="com.sungard.dao.EmployeDAO"> <property name="hibernateTemplate"> <ref bean="hibernateTemplate" /> </property> </bean> <!-- ========================= Start of SERVICE DEFINITIONS ========================= --> <!-- Service Definition --> <bean id="EmployeServiceTarget" class="com.sungard.service.EmployeService"> <property name="empDao"> <ref local="empDao" /> </property> </bean> <!-- Transactional proxy for the TODO Service --> <bean id="empServ" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager" /> </property> <property name="target"> <ref local="EmployeServiceTarget" /> </property> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> </beans>
ATTENTION: There should always be a submitted value for an input if it is rendered, its form is submitted, and it was not originally rendered disabled or read-only. You cannot submit a form after disabling an input element via javascript. Consider setting read-only to true instead or resetting the disabled value back to false prior to form submission. Component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /faces/AjoutEmploye.jsp][Class: javax.faces.component.html.HtmlPanelGrid,Id: _idJsp1][Class: javax.faces.component.html.HtmlInputText,Id: fonction]}
null
null
null
0.0
null
Partager