Project structure:
root
-WebContent
-mobile
-login.xhtml
-desktop
-login.xhtml
My web.xml will load desktop/login.xhtml onload which uses UserBean as a backing bean, In postconstruct of UserBean, I'm trying to redirect my login to mobile/login.xhtml if the renderkit is mobile. I'm doing this by the following code:
@PostConstruct
public void myPostConstruct(){
String renderKitId = FacesContext.getCurrentInstance().getViewRoot().getRenderKitId();
if(renderKitId.equalsIgnoreCase("PRIMEFACES_MOBILE")){
try
{
FacesContext.getCurrentInstance().getExternalContext().redirect("/mobile/login.xhtml");
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
I'm confused with the absolute path to be given for redirect; I need to move from desktop/login.xhtml to mobile/login.xhtml; how do I do that?