Thursday, 7 January 2016

Vaadin 7

Vaadin1 is an open source framework for developing web applications2 running in your browser. What is interesting is that it uses Java to do it.

It feels like you're programming like Swing in Java, but the results are transferred to your webbrowser using Vaadin. Vaadin is able to do this with the help of the Google Web Toolkit3.

Vaadin can apparently be run on the Google App Engine, if you like.

Vaadin 7 supports the JSR-286 Portlet specification. Several portals are supported. Vaadin also has some deeper integration with Liferay Portal11, in which I am very interested, as it is the one that my website is running on.

I did find a youtube video12 that introduces Vaadin in combination with JEE and NetBeans.

Upgrading to Vaadin 7

One of the problems I encountered, when using Vaadin 74 is that most of the resources available are still referring to Vaadin 6. It is important to notice the differences.

The points in [4] that have been most relevant to me are:
  • com.vaadin.Application class no longer exists. The main entry point to your application is now a com.vaadin.ui.UI, which replaces Application and its main window.
  • Also com.vaadin.terminal.gwt.server.ApplicationServlet has been replaced with com.vaadin.server.VaadinServlet in web.xml and its parameter "application" with "UI" pointing to your UI class, and the application is ready to go. Of course you can use annotations, if you prefer.

Testing

As it is Java, I should have no problem Stubbing the Vaadin framework and junit-testing my code. This to me is a big bonus.

Persistence

Persistence in Vaadin is possible by using the JPAContainer5.

JEE and CDI

I use the Servlet to inject a lot of things I need, and then provide those injected things to my UI. Works flawlessly6.

JEE and JPA together in Vaadin

I found helpful information on how to create a EjbEntityProvider here at [7]. That I can use as a base class for EJBBeans that I can inject in my Servlet and henceforth use in my UI for the JPAContainer.

A full downloadable example is available at [8].

Debugging

I have not had to debug anything, everything just works. But, for those interested, you can find it at [9].

FAQ

I get a "Failed to load the bootstrap javascript: ./VAADIN/vaadinBootstrap.js?v=7.5.5"
See [10]. Extend the @WebServlet annotation withe more than one urlPattern. See the example above.

References

[1] Vaadin
https://vaadin.com/home
[2] Wikipedia - Vaadin
https://en.wikipedia.org/wiki/Vaadin
[3] Google Web Toolkit
http://www.gwtproject.org/
[4] Vaadin Wiki - Mirating from Vaadin 6 to Vaadin 7
https://vaadin.com/wiki/-/wiki/Main/Migrating+from+Vaadin+6+to+Vaadin+7
[5] Book of Vaadin - Chapter 19 - JPAContainer
https://vaadin.com/book
[6] Vaadin Wiki - JEE6 integration with Vaadin 7
https://vaadin.com/wiki/-/wiki/Main/JEE6+integration+with+Vaadin+7
[7] Using JPA Container 2.0 in a JEE6 server
https://vaadin.com/web/matti/blog/-/blogs/using-jpa-container-2-0-in-a-jee6-server
[8] Vaadin Forum - Unable to follow J6EE wiki - NullPointerException
https://vaadin.com/forum/#!/thread/386542/389263?_19_redirect
[9] Book of Vaadin - Chapter 11.3. Debug Mode and Window
https://vaadin.com/book/-/page/advanced.debug.html
[10] Book of Vaadin - 4.9. Deploying an Application
https://vaadin.com/book/-/page/application.environment.html
[11] Liferay
http://www.liferay.com/
[12] YouTube - Java EE 7 with NetBeans and Vaadin
https://www.youtube.com/watch?v=3TompuzySD8

1 comment:

  1. Very useful post. Thanks for including the reference links also.

    ReplyDelete