Bonsoir , je suis débutant en jsf et en hibernate et je veut développer une page web d'authentification ,elle contient deux champs login et mot de passe , donc je doit vérifier ces données entrées par l'user avec ceux qui se trouvent dans ma base de donnée(mysql) .
Mon problème est comment je fait pour récupérer mes donnée de base de donnée pour les comparer avec celle entrée , pour savoir si j'envoie l'user vers son espace d'utilisateur ou vers la meme page d'authentification en signalant qu'il a fait une erreur de saisie .
Voila comment j'ai fait :
Le java beans PersonneBeans:

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
package com.thescreencast.web;
 
import java.util.Iterator;
import java.util.List;
 
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
 
public class PerssonneBean {
	private String login;
	/**
         * 
         */
	private String password;
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
   public String add() throws HibernateException{
		 Session session = null;
		try {
			session = HibernateUtil.currentSession();
		} catch (HibernateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	   List list = session.find("from Candidat");
	   Iterator it = list.iterator();
		/* Iterator it = list.iterator();
		 while(it.hasNext())
		 {
		   Candidat c = (Candidat)it.next();
		   System.out.println(c.getIdCandidat()+"-->" +c.getNom());
		 }*/
	  // if(login.equals("ff")& password.equals("ff"))
		//if(it.hasNext())   
 
	  // return "erreur";
		return "succeC";
   }
 
 
}

Code xml : 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
Voila la page jsf d'authentification authentificationC.jsp :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ 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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
 
	<h:form>
		<h:panelGrid border="1" columns="2">
			<h:outputText value="E-mail:"></h:outputText>
			<h:inputText value="#{perssonneBean.login}" style="width: 188px"></h:inputText>
			<h:outputText value="Mot de passe :"></h:outputText>
			<h:inputText value="#{perssonneBean.password}" style="width: 189px"></h:inputText>
 
		</h:panelGrid>
		<h:commandButton value="valider" action="#{perssonneBean.add}"></h:commandButton>
	</h:form>
</f:view>
</body>
</html>

---------------------->faces-config.xml :
Code xml : 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
<?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>candidat</managed-bean-name>
		<managed-bean-class>com.thescreencast.web.Candidat</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
	<managed-bean>
		<managed-bean-name>perssonneBean</managed-bean-name>
		<managed-bean-class>com.thescreencast.web.PerssonneBean</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
	<navigation-rule>
		<display-name>accueil</display-name>
		<from-view-id>/accueil.jsp</from-view-id>
		<navigation-case>
			<from-outcome>candidat</from-outcome>
			<to-view-id>/authentificationC.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<display-name>accueil</display-name>
		<from-view-id>/accueil.jsp</from-view-id>
		<navigation-case>
			<from-outcome>entreprise</from-outcome>
			<to-view-id>/authentificationE.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<display-name>authentificationE</display-name>
		<from-view-id>/authentificationE.jsp</from-view-id>
		<navigation-case>
			<from-outcome>succeE</from-outcome>
			<to-view-id>/espaceE.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<display-name>authentificationE</display-name>
		<from-view-id>/authentificationE.jsp</from-view-id>
		<navigation-case>
			<from-outcome>erreur</from-outcome>
			<to-view-id>/erreur.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<display-name>authentificationC</display-name>
		<from-view-id>/authentificationC.jsp</from-view-id>
		<navigation-case>
			<from-outcome>succeC</from-outcome>
			<to-view-id>/espaceC.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<display-name>authentificationC</display-name>
		<from-view-id>/authentificationC.jsp</from-view-id>
		<navigation-case>
		            <from-outcome>erreur</from-outcome>
			        <to-view-id>/erreur.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
 
</faces-config>


S'il vous plait si vous pouvez m'aider dite moi ce que je doit faire , merci d'avance pour votre aide .