Im implementing a login in a JSF application and have a problem with the redirection.
I want to make available the login form in every xhtml in the app, but after the login success or fail I want to keep the user in the same page they were when clicked on login.
I have tried to return null in the managedBean methong but that doesnt work because it not refreshes the webPage, I need the page to be refreshed for the view logic to work.
This is the login form:
<h:form id="loginForm" rendered="#{!loginBean.estaLogueado()}">
<p:panel header="#{msg.header_login}">
<h:outputLabel for="login" value="#{msg.login}"/>
<p:inputText id="login" value="#{loginBean.usuario}"></p:inputText><br/>
<h:outputLabel for="pwd" value="#{msg.password}"/>
<p:inputText id="pwd" type="password" value="#{loginBean.password}"></p:inputText><br/>
<p:commandButton action="#{loginBean.login()}" value="Login"/>
</p:panel>
</h:form>
<h:form id="logoutForm" rendered="#{loginBean.estaLogueado()}">
Bienvenido #{loginBean.nombreUsuario}!!<br/>
<p:commandButton action="#{loginBean.logout()}" value="Desconectar"/>
</h:form>
And this is the method in the action attribute:
public String login(){
currentUser = gu.login(usuario, password);
return null;
}
There is a way to return to the xhtml where the user loged, not being a fixed xhtml like "login.xhtml"??