JSF: Can't set managed bean property: 'Nom'.
Bonjour,
Voilà, parce que j'ai des problèmes sur un projet plus gros, j'ai décidé de reprendre les choses à la base!
Je développe avec NetBeans et JSF1.1.
J'ai créé un beans tout simple:
Code:
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
|
public class User {
private String Nom;
private String Prenom;
/** Creates a new instance of User */
public User() {
}
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;
}
} |
Ensuite j'ai créé une page toute simple:
Code:
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
|
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@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=UTF-8">
<title>JSP Page</title>
</head>
<body>
<f:view>
<h:form id="formonglet">
Nom : <h:inputText id="Nom" value="#{User.Nom}" />
</br>
Prenom : <h:inputText id="Prenom" value="#{User.Prenom}" />
</h:form>
</f:view>
</body>
</html> |
Ensuite pour que le beans soit managé j'ai été dans Faces-Config.xml
Code:
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
|
<?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">
<!-- =========== FULL CONFIGURATION FILE ================================== -->
<faces-config>
<managed-bean>
<managed-bean-name>User</managed-bean-name>
<managed-bean-class>User</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>Nom</property-name>
<property-class>java.lang.String</property-class>
<value>aa</value>
</managed-property>
<managed-property>
<property-name>Prenom</property-name>
<property-class>java.lang.String</property-class>
<value>a</value>
</managed-property>
</managed-bean>
</faces-config> |
Temps que j'y suis je fournis également web.xml:
Code:
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
|
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list><welcome-file>
index.jsp
</welcome-file></welcome-file-list></web-app> |
Voilà, mon problème est que j' ai l'erreur suivante et que je ne sais pas pourquoi :
javax.faces.FacesException: Can't set managed bean property: 'Nom'.
J'ai les getters et setters publics. Il y a quelque chose que je n'ai pas vu ?
Merci de votre aide