bonjour tous le monde.
voila j'essaye tester la rediriction d'un utilisateur qui saisie des valeurs, soit la page accept si valeur correcte, soit vers failed si un valeur manque.
voila mon faces-config.xml
mon bean:
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 <?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_1_2.xsd" version="1.2"> <managed-bean> <managed-bean-name>connApp</managed-bean-name> <managed-bean-class>jsfbean.ConnApp</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <navigation-rule> <display-name>login</display-name> <from-view-id>/login.jsp</from-view-id> <navigation-case> <from-outcome>echec</from-outcome> <to-view-id>/failed.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>login</display-name> <from-view-id>/login.jsp</from-view-id> <navigation-case> <from-outcome>reussie</from-outcome> <to-view-id>/Accept.jsp</to-view-id> </navigation-case> </navigation-rule> </faces-config>
mon Page JSF <login.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 package jsfbean; public class ConnApp { private String nom; private String passWord; public ConnApp(){} public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } public String getPassWord() { return passWord; } public void setPassWord(String passWord) { this.passWord = passWord; } public String Validation(){ if (this.nom.isEmpty()){ return "echec"; } if (this.passWord.isEmpty()){ return "echec"; } return "reussie"; } }
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 <%@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>Connexion</title> </head> <body> <f:view> <h:panelGrid border="0" columns="2"> <h:outputText value="Nom Utilisateur : "></h:outputText> <h:inputText value="#{connApp.nom}"></h:inputText> <h:outputLabel value="Mot de passe : "></h:outputLabel> <h:inputSecret value="#{connApp.passWord}"></h:inputSecret> </h:panelGrid> <h:form> <h:commandButton value="Connexion" action="#{connApp.Validation}"></h:commandButton> </h:form> </f:view> </body> </html>c'est ca l'erreur que j'ai. je sais ce veut dire l'erreur. par contre ma question est : pourquoi il ne met pas de valeur dans les propriete (nom et password) du bean du moment que moi j'ai rensiegne les deux valeur dans le formulaire?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 javax.servlet.ServletException: #{connApp.Validation}: java.lang.NullPointerException
les gars je compte sur vous.
Partager