Geertjan is a DZone Zone Leader and has posted 457 posts at DZone. You can read more from them at their website. View Full User Profile

Vaadin and NetBeans: Transporting Desktop Users to the Web

04.17.2014
| 6716 views |
  • submit to reddit
Bruno Freitas lives and works in Porto, Portugal, at BMAC, a private healthcare company. He is a software engineer building internal applications, while handling integration requirements with 3rd party software. As needed, he also manages Linux servers, databases, and network systems.

Two of his favorite tools and technologies are Vaadin and NetBeans IDE. I interviewed him about this combination, to find out why he chose each, and what he thinks of the integration between them.

You're doing a lot of web development and you've been using Vaadin. How did that happen and how did you make that decision?

I started developing Java applications in 2005, with Swing, using NetBeans IDE, in the early days of the "Matisse" GUI Builder because fortunately the team realized that understanding and working programmatically with Swing layouts would be important.

In 2009, new projects arrived and "the Web" was the new challenge. So, there was the moment of Java Web Framework selection. The team did some research and we evaluated Spring, Struts, GWT, Ext-GWT, Smart-GWT, and Vaadin.

There were multiple aspects that made Vaadin the best choice for us. For example, at that time, Struts and Spring were probably the main popular frameworks, but the learning curve was big and the "time to market" could be more than was desirable. Besides that, they didn't have widget sets. They did, however, have lots of XML configuration and others things like that.

We evaluated pure GWT applications and were happy with the responsiveness and the programming model, but there was a lack of widgets, so we decide to try the GWT-dependent frameworks. With Smart and Ext GWT, the GUI logic is compiled to JavaScript and executed on the client side. There are pros and cons with that, such as the few server roundtrips for things that could be executed exclusively on client, but all the business UI logic resides on the client. And the license model was not so attractive, either.

In the end, with Vaadin we feel back at home with Swing layouts and a great Web-oriented widget set, together with great performance and incredible productivity. With Vaadin, the UI-business logic resides on the server, while the client only renders the widgets and, on each user event, the request is processed on the server. That could be a con, if the process were not as optimized as it is.

 
Can you briefly describe how Vaadin works, what's unique about it, for anyone who doesn't know about it?

What best describes Vaadin is the server-side programming model. It lets you forget that you are programming for the Web. You can add any JAR dependency to your application, but when you run the project, you will see the application running on every browser with the same aspect, performance, and functionality. You can build web applications without knowing what HTML or JavaScript is.

Basically, the Vaadin server-side application architecture relies on a server-side framework and a client-side engine (GWT). This engine runs in the browser (JavaScript), rendering the UI, and all user interactions are forwarded to the server-side for processing, using AJAX calls. The data is serialized using JSON for better performance. The UI logic is handled by a Java servlet (VaadinServlet that extends HttpServlet). The architecture of the framework leaves you to enjoy programming Java EE applications without the need of handling its inherent complexity. That leaves you to focus on domain and business logic.

Here you can view some screens of an application I work on (click to enlarge them):


 
What do you consider to be the top Vaadin features?

  • The simplicity of the framework that empowers the developer to build Java EE aplications and build rich complex layouts.
  • All the APIs are well documented at https://vaadin.com/api. More than that, there is a nice readable free e-book that you can download from https://vaadin.com/book.
  • You can ask any question on an active forum at https://vaadin.com/forum. For sure, you will get an answer. But if you need more powerful support, you can subscribe to a pro account that gives you another level of support at https://vaadin.com/support.
  • Vaadin Directory, at https://vaadin.com/directory, is a place were you can download and publish Vaadin addons. For example, you can download an addon that supports Spring integration or CDI. There are many great addons that you can use. 
  • One nice and easy way to learn the framework is to view the demo sampler at http://demo.vaadin.com/sampler.
  • Finally, I must refer to the beautiful, polished, and complete widget set components available out of the box. Even better, the support of themes and personalizations provided by Runo, Reindeer, Chameleon, and the upcoming Valo.

But, like you mentioned earlier, a lot of work is done by Vaadin on the server. Is this never a problem?

There are some challenges that this fact raises up, but in most cases there are UI alternatives or a workaround for solving the situation.

For example, we had a case that in a textfield, where the user presses enter for each product to add, the system had to process the inserted product code very quickly and repeatedly. What happened was that sometimes the product code concatenated with the previous code, because  the server (and database access) roundtrip were not as fast as the user. What we did was to create a custom textfield that clears the value on the client side right after the server request, thus we were not wating for the server response.

Another issue that is related with this model is the difficulty to order a client refresh from the server. With Vaadin 7.1 this issue was eliminated since the framework now supports Server Push using WebSockets.  

What kinds of applications is Vaadin best suited for?

There is no doubt to me that Vaadin best suits Rich Internet Applications (RIA). If you want to successfully transport your desktop application users to the Web, Vaadin is really a good choice. That was what happened to me. With the Chrome browser in application mode and Vaadin UIs, most users didn't realize that they were running a web application.   

In my case, the Vaadin apps I'm working on are only for internal/private usage. The main Vaadin app that I create and am responsible for is the frontoffice of our multiple laboratories with multiple points of sample collection. The main features are as follows:

  • Create and search patients.
  • Create healthcare episodes (patient diagnostic and treatment procedures) with multiple specialities, requisitions, and orders, such as Glucose, Cholesterol, and others exams.
  • The system generates barcode samples, which are printed via EPL silently and directly to the appropriate printer via VPN, for the orders and creates the needed invoices for the patient and for the conversion, if there are co-payments.
  • Backoffice tasks for invoicing, managment, and control.

And you've been using NetBeans together with Vaadin -- is that a good combination?

It is very good. NetBeans is my preferred IDE. You can install the Vaadin plugin from the Plugin Manager under the Tools menu and start a Mavenized Vaadin project from templates in the New Project wizard.

Then you can start customizing your application and include addons from the Vaadin directory right in the middle of the code (where you need the addon). Here is an example below.

The POM is generated and managed for you. If needed, in NetBeans IDE, you can view the POM in a graph to better understand the dependency hierarchy.

One nice feature that lets you become more productive is the possibility to run your application within the Embedded WebKit JavaFX Browser, as shown here. 

In this example, you can view/edit the code and see the results right in your IDE.
 
What are your three favorite NetBeans features for Vaadin developers?

  1. The Vaadin NetBeans plugin is really good for wizard-based project creation and preferences settings, but the possibility to search and include inline an Addon is really brilliant. The dependencies are immediately configured in the POM.
  2. The Vaadin code completion enables reading and browsing documentation inline.
  3. NetBeans itself is an amazing IDE for any Java project.

Anything else you want to share?

At the moment, I am starting a new project that uses JDK 8, Java EE 7, Vaadin 7 with the JPA Container Addon, all managed by NetBeans IDE 8.0. I think this is a nice combo for RIA development.

Thanks for taking this interview, Bruno!

Published at DZone with permission of its author, Geertjan Wielenga.