Hello I have two XHTML pages: 1-login.jsf 2-menu.jsf i m trying to go from page1 to page2 by clicking on a button but it doesnt work.Here is my code: login.jsf
<!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:h="http://java.sun.com/jsf/html">
<head>
<link rel="stylesheet" type="text/css" href="../css/styles.css"/>
</head>
<h:body>
<h:form id="LoginForm">
<h:panelGrid style= "width: 467px; height: 88px">
<h:outputLabel value="Login"/>
<h:inputText value="#{loginBean.login}" id="loginID" />
<h:message for="loginID" tooltip="true" showDetail="true" showSummary="true" style="COLOR: #ff0000;"/>
<h:outputLabel value="Mot de Passe"/>
<h:inputSecret value="#{loginBean.password}" id="pwdID" />
<h:message for="pwdID" tooltip="true" showDetail="true" showSummary="true" style="COLOR: #ff0000;"/>
<h:message />
</h:panelGrid>
<h:commandButton id="validerID" value="Valider" action="#{loginBean.authentification}" type="submit"/>
<h:commandButton id="resetID" value="Reset" type="reset"/>
</h:form>
</h:body>
</html>
And here is the code of the ManagedBean:
package com.fst.bibliotheque.beans;
import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext;
public class LoginBean {
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 authentification(){
FacesContext fc=FacesContext.getCurrentInstance();
if("admin".equals(this.login) && "admin".equals(password)){
return "success";
}else{
if(!"admin".equals(this.login)){
fc.addMessage("LoginForm:loginID",new FacesMessage(FacesMessage.SEVERITY_INFO,"Validation Login","Login "+this.login+" inexistant!!"));
}
if(!"admin".equals(this.password)){
fc.addMessage("LoginForm:pwdID",new FacesMessage(FacesMessage.SEVERITY_INFO, "Validation Pwd","Vérifier votre mot de passe!!"));
}
return "echec";
}
}
}
Finally here is the navigation rules in faces-config.xml
<navigation-rule>
<display-name>pages/login.xhtml</display-name>
<from-view-id>/pages/login.xhtml</from-view-id>
<navigation-case>
<from-action>#{LoginBean.authentification()}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/pages/menu.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
I have this in my console after execuring applcation: janv. 09, 2014 11:00:41 PM com.sun.faces.renderkit.html_basic.MessageRenderer encodeEnd WARNING: 'for' attribute cannot be null Any one know where is the problem?