Blog

Credible mobile Java EE apps

By  
Matti Tahvonen
Matti Tahvonen
·
On Jun 30, 2014 8:00:00 PM
·

A couple of weeks ago we had a webinar with a nice overview of a Vaadin TouchKit application built on top of a well established Java EE architecture. Some viewers even called it a "TouchKit essentials for Java EE gurus", but we are pretty happy about the content we covered there. You should consider it more as a best practices for a serious TouchKit application.

Proven software stacks, like Java EE 6 or Spring, are safe choices upon which you can build your apps. They have been used in thousands of huge projects, both in terms of usage and features, in multiple industries. There shouldn't be nasty surprises, something you are likely to face in case you design a whole new stack yourself.

Java EE mobile stack explained

For those who like to read more than watch videos, here is a short summary of the topics we covered.

In the very beginning of the webinar, we presented a way to get Context Dependency Injection set up with TouchKit. Too bad, I made a shameful demo effect in the webinar and forgot to add an empty beans.xml file to the project, but a working example of integrating CDI with TouchKit is now available from GitHub.

When you end up having lots of code on the UI layer, it is essential to start building that in a formulated manner. A commonly used pattern is Model-View-Presenter, MVP, which was demonstrated from our hobby project. There your model usually comes from your "backend", View classes contain only Vaadin UI components - without any logic, and Presenter classes contain logic related to user interactions.

The well known MVP pattern will help you to collaborate when new developers are added to the project or when you return to the project after some months on some other task. But an even more essential benefit is that you can pretty easily write fast JUnit tests for your UI logic. The webinar discusses this kind of tests, where model and view parts are mocked for the test.

Testing it

Testing just the UI controllers in your web app doesn't yet prove your app works flawlessly. To demonstrate how you can also test your domain model together with services and database, we used Arquillian. It is an increasingly popular integration testing helper for Java EE environments that allows you to quickly create minimal deployments, deploy them in a container and run tests on them. It makes running integration tests during the development just as easy as running unit tests.

To make the integration level even higher, we threw in Vaadin TestBench. It is a testing tool, designed specifically for Vaadin apps, that commands real browsers to simulate user interactions. This way you can use it to create tests that really prove your whole app works - from the browsers’ JS interpretation to SQL queries in your database. We also used Page Object pattern to make parts of these tests reusable among different user stories and to make them more maintainable. TestBench naturally supports Vaadin TouchKit and you can even configure it to use real mobile devices.

Pretty heavy topics for a one hour webinar, but in case you are considering to build some serious Vaadin TouchKit apps, definitely worth watching.

BTW. Those who prefer Spring over Java EE, most topics are still relevant. For a Spring Boot + Vaadin Touchkit integration example, check out this small hobby project to track the Vaadin sailing boat.

Some further pointers and inspiration:

 

Matti Tahvonen
Matti Tahvonen
Matti Tahvonen has a long history in Vaadin R&D: developing the core framework from the dark ages of pure JS client side to the GWT era and creating number of official and unofficial Vaadin add-ons. His current responsibility is to keep you up to date with latest and greatest Vaadin related technologies. You can follow him on Twitter – @MattiTahvonen
Other posts by Matti Tahvonen