Change renderkit and redirect

UI Components for JSF
Post Reply
hondus
Posts: 5
Joined: 14 Oct 2014, 16:15

20 Nov 2014, 13:44

Hello,
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);
            }
        }
    }
}
(ofc declared own ViewHandler in faces-config)

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

Image

could someone help me? Maybe different method to redirect or something

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

21 Nov 2014, 00:34

Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests