im just tying to make cross-platform app.
Im following this tutorial:
http://forum.primefaces.org/viewtopic.php?f=8&t=19887
I made View handler same as on link above, user same UserAgentInfo with isMobile() method, and also implemented managedBean like this which should redirect to mobile page when renderkit is PRIMEFACES_MOBILE
Code: Select all
@ManagedBean
@SessionScoped
public class MyBean {
@PostConstruct
public void myPostConstruct() {
String renderKitId = FacesContext.getCurrentInstance().getViewRoot().getRenderKitId();
if (renderKitId.equalsIgnoreCase("PRIMEFACES_MOBILE"))
{
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("mobile.xhtml"); //contains only outputtext with //value="mobile"
} catch (IOException ex) {
Logger.getLogger(MyBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
index.xhtml
Code: Select all
<?xml version='1.0' encoding='UTF-8' ?>
<!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://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:outputText value="#{request.getHeader('user-agent')}"/>
<p:spinner/>
</h:body>
</html>
only renderkit is changed but im not getting redirected to mobile page
could someone help me? Maybe different method to redirect or something