salut
j'ai un problème avec l'identfication d'un bean. je travaille sur un projet web dynamique sous eclipse.
c'est qu'il n'a pas été créé mais je ne comprends pas la cause!
merci pour votre aide
faces-config.xml
WebContent/Ajouter.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 <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <managed-bean> <managed-bean-name>bean</managed-bean-name> <managed-bean-class>beans.Personne</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <navigation-rule> <from-view-id>Ajouter.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>Confirmer.jsp</to-view-id> </navigation-case> </navigation-rule> </faces-config>
Personne.java
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 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@taglib uri="http://java.sun.com/jsf/core" prefix="c" %> <%@taglib uri="http://richfaces.org/rich" prefix="rich" %> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <!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>Ajouter</title> <style type="text/css"> .style1 { border:1px solid black; } </style> </head> <body> <f:view> <h:form> <table style="width: 68%" class="style1"> <tr> <td style="width: 147px">Nom</td> <td style="width: 23px">:</td> <td colspan="2"> <h:inputText id="nom" value="#{bean.nom}" style="width: 244px"/> </td> </tr> <tr> <td style="width: 147px">Prenom</td> <td style="width: 23px">:</td> <td colspan="2"><h:inputText id="prenom" value="#{bean.prenom}" style="width: 244px" /> </td> </tr> <tr> <td style="width: 147px">Age </td> <td style="width: 23px">:</td> <td colspan="2"><h:inputText id="age" value="#{bean.age}" style="width: 244px"/></td> </tr> <tr> <td style="width: 147px">Date de naissance</td> <td style="width: 23px">:</td> <td colspan="2"> <rich:calendar value="#{bean.date_naissance }" required="false" cellWidth="18px" cellHeight="16px" datePattern="MMM d,yyyy"/> </td> </tr> <tr> <td style="width: 147px"></td> <td style="width: 23px"></td> <td style="width: 271px"></td> <td><h:commandButton action="#{bean.AjouterPersonne }" value="Ajouter"/></td> </tr> </table> </h:form> </f:view> </body> </html>
erreur:
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 package beans; import java.util.Date; import org.hibernate.classic.Session; import util.HibernateUtil; public class Personne { private int id_personne; private String nom; private String prenom; private int age; private Date date_naissance; public int getId_personne() { return id_personne; } public void setId_personne(int id_personne) { this.id_personne = id_personne; } 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 int getAge() { return age; } public void setAge(int age) { this.age = age; } public Date getDate_naissance() { return date_naissance; } public void setDate_naissance(Date date_naissance) { this.date_naissance = date_naissance; } public String AjouterPersonne() { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Personne p = new Personne(); p.setNom(this.nom); p.setPrenom(this.prenom); p.setAge(this.age); p.setDate_naissance(this.date_naissance); session.save(p); session.getTransaction().commit(); return "success"; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/TutorielJSF2] threw exception [/Ajouter.jsp(26,0) '#{bean.nom}' Target Unreachable, identifier 'bean' resolved to null] with root cause org.apache.jasper.el.JspPropertyNotFoundException: /Ajouter.jsp(26,0) '#{bean.nom}' Target Unreachable, identifier 'bean' resolved to null at org.apache.jasper.el.JspValueExpression.getType(JspValueExpression.java:63) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95) at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030) at javax.faces.component.UIInput.validate(UIInput.java:960)
Partager