Bonjour les amis,
mon problème est lorsque j'utilise un bean avec jsf et je veux enregistrer une valeur tapée au clavier dans une propriété du bean; au lieu de cela je vois affiché dans le champs text en letrre : #{authentification.login}. Ci-dessous, le code de mon projet :
web.xml:
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 <?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"> <welcome-file-list> <welcome-file>faces/index.jsp</welcome-file> </welcome-file-list> <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>
faces-config.xml:
index.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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 <?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> <navigation-rule> <from-view-id>/index.jsp</from-view-id> <navigation-case> <from-action>#{authentification.redirectionAuth}</from-action> <from-outcome>admin</from-outcome> <to-view-id>/admin.jsp</to-view-id> <redirect /> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/index.jsp</from-view-id> <navigation-case> <from-action>#{authentification.redirectionAuth}</from-action> <from-outcome>fd</from-outcome> <to-view-id>/fd.jsp</to-view-id> <redirect /> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/index.jsp</from-view-id> <navigation-case> <from-action>#{authentification.redirectionAuth}</from-action> <from-outcome>rf</from-outcome> <to-view-id>/rf.jsp</to-view-id> <redirect /> </navigation-case> </navigation-rule> <managed-bean> <managed-bean-name>authentification</managed-bean-name> <managed-bean-class>metier.Authentification</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>
Autrement dit, comme si JSF ne peux pas interpreter le EL Expression :
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 <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <f:view> <html> <body> <h:form> <h:panelGrid columns="2"> <h:outputText value="Login : "/> <h:inputText value="#{authentification.login}" size="30"/> <h:outputText value="Password : "/> <h:inputSecret value="#{authentification.password}" size="30"/> <h:commandButton action="#{authentification.redirectionAuth}" value="Se connecter"/> <h:messages/> </h:panelGrid> </h:form> </body> </html> </f:view>
#{authentification.login}, et le considère par la suite comme une chaine de caractère.
J'ai besoin de votre aide.
Merci d'avance les amis.
Partager