tags:

views:

5

answers:

0

Hi all! I need your help! I have a jsf app, which now have 2 versions - one for mobile and one for desktop browsers. The pages for desktop lie in folder /html, and for mobile - /html/mobile. I want one outcome decide what exactly pages to show - from /html or from /html/mobile.
I create session attribute isMobileBrowser - which indicates what browser I have.

 Boolean isMobileBrowser = (Boolean) session.getAttribute("isMobileBrowser");
  if (isMobileBrowser == null) {
 Enumeration e = req.getHeaders("user-agent");
while(e.hasMoreElements()) {
 String str = e.nextElement().toString().toLowerCase();
 if (str.indexOf("mobile") != -1) {
  isMobileBrowser = new Boolean(true);
  System.out.println("MOBILE BROWSER");
 } else {
  isMobileBrowser = new Boolean(false);
  System.out.println("STANDARD BROWSER");
 }
 session.setAttribute("isMobileBrowser", isMobileBrowser);
}

}

And now I want somethin like that:

 <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
     <from-outcome>clientadmin</from-outcome>
                    // if mobile
         <to-view-id>/html/mobile/clientadmin.jsf</to-view-id>
                      // if desktop
                      <to-view-id>/html/clientadmin.jsf</to-view-id>
      </navigation-case>
   </navigation-rule>

How I can do it better. I find out NavigationHandler, but dont understand how it works. I also try with conditions in xml - but I dont think they work (I use jsf 2.0).

Any help will be greate! Thanks!