Friday, December 14, 2012

Vaadin Touchkit vs ZK Mobile vs platform specific mobile applications

I was exploring vaadin and zk technologies for mobile devices and found these 2 technologies for it : Vaadin Touchkit and ZK Mobile.and found some below interesting points in terms of different development aspects that one should consider before using these technologies.

NOTE: I think ZK Mobile is obsolete. and not used by anyone as of now. It was released in 2008 i think and then not been upgraded.

1) Scope of Mobile Applications:
Today mobile applications comes in different categories and functionalities. So before using any Vaadin touchkit or ZK Mobile, application scope should be defined properly.

If your application needs to be native application in any platform like android, ios or java, then you should not use these technologies for development. What i mean by native mobile application is an application that requires to use OS features like notifications, alarm services, account services etc...
If your application requires to use any of the features provided by underlying operating system on which application is going to run, then Vaadin Touchkit or ZK Mobile will not help.

ZK mobile and Vaadin Touchkit are mainly developed for building web applications for mobile devices.

2) Productivity:
If you have already a web application developed in ZK or Vaadin, and you want to have it for mobile device, then you can do it easily by Vaadin Touchkit or ZK Mobile.

Your existing web application might have very rich UI which is developed for desktop browsers, which might not be handled by your mobile browser. So you can use Vaadin Touchkit or ZK Mobile to build mobile specific web app out of it easily.

In this you can use most of your existing backend logic.

But if you are planning to build a mobile application that would require to use mobile platform specific features then these technologies might not help. In that case you have to build OS specific mobile applications.

So if you are planning to develop a mobile web application, then ZK Mobile or Vaadin Touchkit are best. and will offer a great productivity.

3) User Experience:
Platform specific mobile application will definitely offer a rich and smooth user experience than Vaadin touchkit or ZK Mobile.

Vaadin Touchkit also offers very good user experience and provides wide range of UI components to apps.
Its default iOS theme provide almost iOS like UI and it also offers many other themes too.  
But this will not run as smooth as platform specific mobile apps. as ultimately it will not completely leverage the real power of mobile platform features as finally it is going to run in a mobile web browser. as compared to native mobile apps.

Zk Mobile supports very few UI components like Button, Frame, Label, Image, Textbox.. It has not been upgraded for a long time.
ZK Mobile also requires an application on mobile devices to run ZK Mobile apps. ZK Mobile apps are deployed on web servers like tomcat, jboss, weblogic or other. and to run those applications on mobile device it will require an application developed by ZK Team.
For example, to run ZK Mobile Apps on android, you have to install zkand.apk android application on your android phone. This zkand.apk application will act as a browser for ZK Mobile Apps.

4) Learning Curve:
If you are a vaadin developer then Vaadin Touchkit will be very easy to use. and if you are a ZK developer then there is no learning curve for this.
You can easily use these technologies if you have a development background on ZK or Vaadin.

If you dont have an experience in ZK or Vaadin. and wanted to build a fresh application then i would suggest to learn and build platform specific mobile applications. i mean android or iOS or J2ME. This way there will not be any limitations in providing any kind of feature.

And for android, if you already worked in AWT/Swing, then it would be very easy to learn and build an android application.

5) Cost:
ZK Mobile is free to use. You don't have to purchase any license to use it.

Vaadin Touchkit is not free. Its license price starts from 750USD.

Platform specific mobile apps can be developed freely if you know how to build it using android/iOS/J2ME etc.. There is no license to buy for this.

For comparison between ZK framework and Vaadin Framework visit blog post: Zk Vs Vaadin


Please correct me by posting your comments if anything seems wrong in above content.

References:
https://vaadin.com/home
https://vaadin.com/add-ons/touchkit
https://vaadin.com/directory#addon/vaadin-touchkit
http://www.zkoss.org/product/zk
http://www.zkoss.org/product/zkmobile
http://java.com/en/download/faq/whatis_j2me.xml
http://www.oracle.com/technetwork/java/javame/index.html
http://www.android.com/
http://developer.android.com/index.html
http://www.apple.com/ios/
http://www.javaworld.com/javaworld/jw-07-1996/jw-07-awt.html
http://docs.oracle.com/javase/tutorial/uiswing/
http://sourceforge.net/projects/zk1/files/ZK%20Mobile%20Document/zkmob-doc-0.8.10/ZKMobile-quickstart-0.8.10.pdf/download?use_mirror=citylan&download=
http://sourceforge.net/projects/zk1/files/ZK%20Mobile%20for%20Android%20Document/zkand-doc-0.8.2/ZKMobile-for-Android-quickstart.pdf-0.8.2.pdf/download

Friday, September 28, 2012

Cross Origin Resource Sharing (CORS) for Java Web Applications

When we have to include web resource from different origins then CORS comes into picture.

CORS defines how browsers and servers communicate when accessing sources across origins using HTTP headers to allow both the browser and the server to know enough about each other to determine if the request or response should succeed or fail.

Consider we have a web app app1 and app2. If we have to include resource from app2 into app1 using ajax, then we have to implement CORS into app2 web application.

Because when we make an ajax call from app1 it will get converted to CORS request call by browser. so those request should be handled at app2.

To implement it we have to configure 1 filter into app2.
com.thetransactioncompany.cors.CORSFilter

To include above filter you have to download and copy jar cors-filter-1.3.2.jar into app2/webcontent/WEB-INF/lib.

download it from : http://software.dzhuvinov.com/cors-filter-configuration.html

then you have to configure filter into web.xml
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>

<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>x-requested-with</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

Example:

Consider you have 2 web application whose context roots are app1 and app2.

You have app1/page1.html and you want to insert the content from app2/page2.html to app1/page1.html.

app2/page2.html
<html>
<body>
app2 page2.html content here
</body>
</html>

app1/page1.html
<html>
<head>
<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>

<script>
jQuery(document).ready(function(){
jQuery("#div1").load("/app2/page2.html");
});
</script>
</head>
<body>
<div1 id="div1">
</div1>
</body>
</html>

Above code will insert the content from app2/page2.html into div1 of app1/page1.html.

For java web application, make sure you have filter mapping for html as below for above example to work.
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>