Bonjour, je n'arrive pas accéder aux propriétés de mes managedBean. Voici comment ils sont déclarés:
faces-config.xml:
Mon mangedbean UserBean.java:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <faces-config> <managed-bean> <managed-bean-name>userBean</managed-bean-name> <managed-bean-class>com.jsfcompref.register.UserBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>firstName</property-name> <property-class>java.lang.String</property-class> <value/> </managed-property> </managed-bean> </faces-config>
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 public class UserBean{ String firstName; public UserBean() { } public String getFirstName() { System.out.println("get first name"); return firstName; } public void setFirstName(String firstName) { System.out.println("set first name"); this.firstName = firstName; } public String addConfirmedUser() { System.out.println("Adding new user"); return "success"; } }
Voici comment j'accèdes aux propriétés de mon bean:
En écriture:
En lecture:
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 <%@ page contentType="text/html"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <f:view> <html> <head> <title>A Simple JavaServer Faces Registration Application</title> </head> <body> <h:form> <h2>JSF Registration App</h2> <h4>Registration Form</h4> <table> <tr> <td>First Name:</td> <td><h:inputText value="#{userBean.firstName}" required="true" id="fname" /> <h:message for="fname" /></td> </tr> </table> <p> <h:commandButton value="Register" action="register" /> </p> </h:form> </body> </html> </f:view>
Que ce soit dans mon outputText ou mon inputText, j'aperçois toujours :"#{userBean.firstName}". J'ai inséré des system.out.printl dans mes getter et setter. Et ces messages ne sont jamais apparu alors que le message s'affichant lors du clique sur le bouton "confirm" est bien présent.
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 <%@ page contentType="text/html"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <f:view> <html> <head> <title>A Simple JavaServer Faces Registration Application</title> </head> <body> <h:form> <h2> JSF Registration App </h2> <h4> Registration Confirmation </h4> <table> <tr> <td>First Name:</td> <td> <h:outputText value="#{userBean.firstName}"/> </td> </tr> </table> <p><h:commandButton value="Edit" action="revise"/> <h:commandButton value="Confirm" action="#{userBean.addConfirmedUser}" /> </p> </h:form> </body> </html> </f:view>
Qui peut me dire d'où vient mon problème,
Cordialement,
tupac25
Partager