How to redirect to two different pages in pages.xml
fmm1977 Apr 23, 2012 5:27 PMHi everyone, mi question is based in redirecting to one page or another according to a value passed by URL. For example:
this is the link:
http://localhost:8080/Refund/home.seam?user=012012&name=john&auth_level=4
the site with this data loads a certain xhtml page (i.e: page1.xhtml)
like pages.xml says:
<page view-id="/home.xhtml" >
<action if="#{authenticator.limpiar}" execute="#{identity.login}" />
<param name="user" value="#{user.rut}" />
<param name="emp" value="#{user.empRut}" />
<param name="auth_level" value="#{user.authLevel}" />
<navigation from-action="#{identity.login}" >
<rule if="#{identity.loggedIn}" >
<redirect view-id="/pages/page1.xhtml" />
</rule>
<rule if="#{not identity.loggedIn}">
<redirect view-id="/errorLogin.xhtml"/>
</rule>
</navigation>
</page>
now we added another parameter called &emp_id=1, so the URL now is :
http://localhost:8080/Refund/home.seam?user=012012&name=john&auth_level=4 &emp_id=1
and added to pages.xml : <param name="emp_id" value="#{user.emp_id}" />
the thing is that emp_id can be 1 or 15 and depending that number we need to redirect to one page or another. How can i do that?
in pages.xml? or in authenticator.java?
this is the code.
package cl.exe.sm.reembolso.action;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Identity;
import cl.exe.sm.reembolso.bean.BusquedaBono;
import cl.exe.sm.reembolso.pojo.User;
import cl.exe.sm.reembolso.procedures.ManejadorProcedimientos;
@Name("authenticator")
public class Authenticator
{
@Logger private Log log;
@In Identity identity;
@In @Out Usuario user;
@Out BusquedaBono busquedaBono;
public boolean authenticate()
{
boolean resultado = false;
log.info("Inicio:authenticate()");
log.info("Autenticando usuario {0}", user.getRut());
user= ManejadorProcedimientos.autenticarUsuario(user);
if (usuario.getPerId() == 4){
log.info("Usuario autenticado");
resultado = true;
}
log.info("Fin:authenticate()");
return resultado;
}
public boolean getLimpiar(){
busquedaBono = new BusquedaBono();
return true;
}
}
thanks for your responses!!!!