pb de navigation entre les pages jsf !
bonjour a tous;
je suis débutant en JSF et j'arrive pas à passer d'un formulaire (dans la page "index.jsp") à une autre page( soit page d'erreur soit page de succès) à l'aide d'un "validateur" (beancontroller2.java).
en fait,
le code de la page index.jsp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MY First Application JSF</title>
</head>
<body>
<br> <h2> My First Application </h2><br><br>
<core:view>
<html:form>
<html:outputText value="Nom Prénom " />
<html:inputText value="#{beancontroller1.noun}"> </html:inputText><br>
<html:outputText value="Adresse Email " />
<html:inputText value="#{beancontroller1.email}"></html:inputText>
<html:commandButton value="Connecter" action="#{beancontroller2.loginConnect}"/>
</html:form>
</core:view>
</body>
</html> |
le code du contrôleur beancontroller2.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
package beanPackage;
public class BeanController2 {
private String email = "user@host";
private String name = "";
public String loginConnect() {
if (this.email.isEmpty()) {
return "Rejected";
}
if (this.name.isEmpty()) {
return "Rejected";
}
return "Accepted";
}
} |
et voici le fichier 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
|
<?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">
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>accepted</from-outcome>
<to-view-id>/accepted.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>rejected</from-outcome>
<to-view-id>/rejected.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name> beancontroller2 </managed-bean-name>
<managed-bean-class> beanPackage.BeanController2 </managed-bean-class>
<managed-bean-scope> none</managed-bean-scope>
</managed-bean>
</faces-config> |
le serveur en dirait recharge la page index.jsp quand je tape connecter au lieu de traiter les chapms nom et email ...!!
plz help me et merci d'avance ..!!!:cry::cry::cry::cry::cry:
mé il n'ya pas eu de changement
salut Sniper37;
alors, le pb a ce que j'ai compris résulte de "beancontroller2.loginConnect" car quand je mis directement "accepted" ou "rejected", la page d'erreur ou de succès s'affiche mais avec cette classe java il n'y a aucune modification ??!! :roll::roll: