Problème de navigation dynamique
Bonjour,
j'ai ma navigation dynamique qui ne fonctionne pas comme je voudrais.
Quelque soit la valeur que j'utilise, la page post submit est celle ou je me trouve et non celle ou je devrais être.
Par ex, en affichant navigation.jsf, si je clique sur le bouton, cela test les champs dans la page et doit me faire aller sur une page de réussite ou d'échec. Mais je reste tout le temps au même endroit... :cry:
Quel est mon problème svp?
Merci d'avance pour vos réponses
JD
Voici mon 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 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
<?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">
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<locale-config />
</application>
<managed-bean>
<description>Visual Bean with reference on Business
Bean.</description>
<managed-bean-name>todoBean</managed-bean-name>
<managed-bean-class>jotodo.gui.bean.ToDoBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>toDoService</property-name>
<value>#{toDoService}</value>
</managed-property>
<managed-property>
<property-name>toDoId</property-name>
<value>#{param.toDoId}</value>
</managed-property>
</managed-bean>
<managed-bean>
<description>Managed bean for Country</description>
<managed-bean-name>countryBean</managed-bean-name>
<managed-bean-class>fr.vacheron.gui.bean.CountryBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>countryService</property-name>
<value>#{countryService}</value>
</managed-property>
<managed-property>
<property-name>countryId</property-name>
<value>#{param.countryId}</value>
</managed-property>
</managed-bean>
<managed-bean>
<description>Managed bean for Country</description>
<managed-bean-name>navigationBean</managed-bean-name>
<managed-bean-class>fr.vacheron.gui.bean.NavigationBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/navigation.jsp</from-view-id>
<navigation-case>
<from-outcome>Accepted</from-outcome>
<to-view-id>/link1.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>Rejected</from-outcome>
<to-view-id>/link2.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/createToDo.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/viewToDos.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/editToDo.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/viewToDos.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/viewToDo.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/viewToDo.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/viewToDos.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/viewToDos.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/countryList.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/countryList.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>countryEdit</display-name>
<from-view-id>/countryEdit.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/countryList.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>countryCreate</display-name>
<from-view-id>/countryCreate.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/countryList.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>countryView</display-name>
<from-view-id>/countryView.jsp</from-view-id>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<!---->
<!--
This JSF variable resolver lets you reference JSF managed beans from a
Spring context, or a Spring bean from a managed bean
-->
<lifecycle />
<factory />
</faces-config> |
Ma NavigationBean.class
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| package fr.vacheron.gui.bean;
public class NavigationBean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
private String email;
public String link1() {
return "success";
}
public String link2() {
return "failure";
}
public String loginConnect() {
if (this.email.isEmpty()) {
return "Rejected";
}
if (this.name.isEmpty()) {
return "Rejected";
}
return "Accepted";
}
} |
Navigation.jsp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<title>Redirection Dynamique à partir dun formulaire</title>
</head>
<body>
<f:view>
<h:form>
<h:outputText value="Nom : " />
<h:inputText value="#{navigationBean.name}" />
<br/>
<h:outputText value="Adresse email : " />
<h:inputText value="#{navigationBean.email}" />
<br/>
<h:commandButton value="Connecter"
action="#{navigationBean.loginConnect}" />
</h:form>
</f:view>
</body>
</html> |