Hi,
I use Jquery mobile,
http://jquerymobile.com.
I keep the same controllers for both versions (desktop and mobile).
However, I created three main templates.
- main.html -> include main.desktop.html or main.mobile.html
- main.desktop.html
- main.mobile.html
When the view is simple I create only one view file which extends
main.html, so according to a session value it's the main.desktop.html
or main.mobile.html which is used.
When the view is not simple I create three view files, for instance
for the index page we have:
- index.html -> include index.desktop.html or index.mobile.html
- index.desktop.html -> extends main.desktop.html
- index.mobile.html -> extends main.mobile.html
To know if a user want to see the desktop or the mobile version, I
always check a request parameters (for instance main.mobile.html) in a
interceptor like that:
String display_mode = request.params.get("display_mode");
if ("mobile".equals(display_mode))
session.put("display_mode", "mobile");
else if (display_mode != null)
session.put("display_mode", "web");
So in the main.html or in index.html I know which page include or
extends:
#{if session['display_mode'] == 'mobile'}#{include
'main.mobile.html' /}#{/if}
#{else}#{include 'main.desktop.html' /}#{/else}
If you want to use jquery mobile by this way, type data-ajax="false"
as attribute of <form> and rel="external" as attribute of <a>
otherwise all will be done in ajax.
To detect the device (desktop or mobile) used by the client, I found
http://code.google.com/p/mobileesp/source/browse/Java/UAgentInfo.java,
but I had not been used it.
bye