Usually, a Java web application consist two parts:
1. the layout template framework, such as Tiles, or Sitemesh.
2. a web framework to handle request and return JSP result page, such as Struts, Spring MVC.
Take my favorite combination, Sitemesh for layout template engine and Spring MVC as web framework for example, there will be two (or three) step for a Sitemesh + Spring MVC web application to go:
1. prepare a Sitemesh mobile decorator (view or template) and config it to render request from mobile browser with the mobile version decorator.
I will write a post on this soon.Done.
Create Mobile Decorator with Sitemesh and jQuery Mobile
2. prepare a Spring MVC interceptor to render mobile request with mobile version JSP page.
There is an excellent post:
Better Mobile Device Detection with a Spring 3 Interceptor
on the mobile intercepter.
(3. provide a JSONP view if you intend to serve mobile application)
There is also anohter excelent post for this:
Tutorial: Implementing a Servlet Filter for JSONP callback with Spring’s DelegatingFilterProxy

for example, in my project, the default.jsp is the default decartor for PC browser. I personally use BlueprintCSS framework, jQuery and jQuery UI to tackle some cross browser problem.
The default-mobile.jsp is for mobile browser and jQuery Mobile can handle browser compatablity too.
For the result page, I also provide two version. Therefore, when user is using mobile phone, Spring MVC will intercept request and return the mobile version result page. Sitemesh will render the mobile version result with mobile decorator. So the mobile user will get tidy, fast mobile view.
In addition, if you intend to develop a mobile application for your web application, Phonegap might be your best choice since you can leverage your css, html and javascript skill and multi-mobile platform supported. Because of the cross domain restriction, JSONP supported will be very helpful for developer.
0 comments:
Post a Comment