Vaadin and NetBeans: Enabling Business Applications on the Web
Join the DZone community and get the full member experience.
Join For Free

he currently lives in london, where he works as a consultant for a british it company.
he maintains two open source products used by several small companies around the world. the first is enterprise app for vaadin , a vaadin add-on to develop crud-based applications, while the second is infodoc pro , a simplified workflow software based on enterprise app for vaadin.
alejandro tweets at @alejandro_du and his website is alejandrodu.com .
aside from and together with vaadin , one of his favorite tools is netbeans ide . after interviewing bruno freitas on the vaadin/netbeans combination, i interviewed alejandro 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, how did you make that decision?
i came across web development when the web was pretty much static html. as a java developer, and after having a look at the old cgi and popular php later, i started to use the struts framework in my first professional job.
after a while of using struts, i started to miss the good feeling that you have when coding the presentation layer using java. i realized that in order for a developer to build web applications, you had to keep getting your fingers dirty with html, javascript, and probably xml on a daily basis. i really missed the ability to use the ide´s refactoring tools to change the the presentation layer. moreover, the world of it is highly dynamic, developers join and leave teams frequently, which means that being able to flatten the learning curve when a junior developer joins a project is a win. having to learn not only the underlying web framework but html and javascript as well, requires an extra effort.
so the search began. after evaluating interesting alternatives such as apache isis, eclipse rcp, wicket, ext js, groovy and grails, and even jsf, flex, and wavemaker, i found that the easiness and flexibility of vaadin was the best choice. you can start working on a vaadin application even if you don't know any vaadin at all.
can you briefly describe how vaadin works, what's unique about it, for anyone who doesn't know about it?
imagine using vaadin for the first time. it's as simple as dropping some jar files inside your "lib" directory and starting to create your ui by coding java classes. of course, you can use the maven archetype or ides wizards to create your project too.
basically, a vaadin application's starting point is the "init" method of the ui class. you need to override this method by extending the ui. let me show you an example:
public class myvaadinui extends ui { @override protected void init(vaadinrequest request) { verticallayout layout = new verticallayout(); layout.addcomponent(new label("hello vaadin!")); setcontent(layout); } }if you have used swing, awt, or any desktop api before, i bet you can easily understand this code. even if you have not used any desktop api before, chances are that you can understand the code. we are simply creating a layout, adding a label to it, and letting the layout be the content of the page. here is a screenshot of this simple application:

similarly, you can add text fields, buttons, combo boxes, tables, trees, and a lot of ready-to use components. you can even extend existing components or create your own components.
vaadin is based on gwt. with gwt, you can define your ui layer using java. the gwt compiler will generate the equivalent javascript, html, and css ready to be rendered in any browser. however, with gwt you will need to code the logic to communicate between client and server. vaadin adds this part, so you don't need to worry about it. with vaadin, all ui state is on the server, which leads to simpler architectures for your applications. look at this piece of code:
button button = new button("click me"); button.addclicklistener(new clicklistener() { @override public void buttonclick(button.clickevent event) { notification.show("thanks for clicking."); } });the buttonclick method will run in the server, so communication between client and server is that simple. and could be simpler if you use java 8 lambdas.
what do you consider to be the top vaadin features?
i like vaadin mostly because of three reasons:
- you can implement your ui layer in java, meaning that you can take advantage of all the object oriented knowledge when you are coding the ui, while truly reusing ui components, something that is difficult when using other web frameworks.
- vaadin includes several ready to use, professional-looking themes.
-
documentation and community is awesome.
what kinds of applications is vaadin best suited for?
most of the applications i have worked on are "business applications" for the financial, communication, and education sectors. some are hosted and accessed inside intranets, while others are deployed to hosting providers and accessed worldwide through the internet. most of them have less than a hundred concurrent users at any time. for all these scenarios, vaadin proved to be an excellent choice.
usually, the primary concerns when deciding whether or not to go with vaadin are scalability and flexibility. there is a study showing that vaadin does scale to an important level. so, i would say that for most projects scalability should not be a limitation when evaluating vaadin. it's true that vaadin is mostly a server-side framework. this means that some extra work is done on the server per request. however, most of the requests are ajax requests that involve changing some part of the client's html instead of the whole page. moreover, you can always use vaadin client-side api to move ui logic to the client side when needed. this last argument can also be used in favor of vaadin when evaluating flexibility. vaadin is a mature framework that offers a high degree of flexibility.
in my opinion, the key point when evaluating vaadin is understanding two important concepts:
-
vaadin keeps the state of the ui in the http session.
-
a javascript client engine containing the logic required to communicate to the server and to get changes is served to the client. this feels like loading an application in the browser and then interacting with the server through this client engine. of course, you don't have to bother about this when developing vaadin applications.
so, if you don't have strong reasons not to use the http session (or keep it very very small in size), and if you can accept loading some not very small (not very large though) javascript in the first request, vaadin is a really good candidate for your presentation layer.
and you've been using netbeans together with vaadin -- is that a good combination?
definitely. i think netbeans was slow prior to 5.5 but now it is a fast ide with probably the best support for maven among the ides. i prefer to use maven for vaadin applications and netbeans feels like the best choice for this.
and i would add another ingredient to the recipe: java 8. lamdas and method references make writing vaadin listeners a delight. netbeans will show hints to convert old listeners to the new lambda notation. moreover, you can use a wizard to convert all pre-lambda expressions into lambdas for the whole project. netbeans support for java 8 is awesome, so netbeans + vaadin + java 8 just rocks!
what are your three favorite netbeans features for vaadin developers?
first, the integration with the vaadin directory that includes a browser to search vaadin add-ons inside netbeans and the ability to use code completion to update the dependencies for vaadin add-ons as you type. for example, if you start typing confirmdialog and press ctrl+space, code completion will show the add-on and if you select it, will update your pom.xml to include the dependency.
second, the project wizards that allows you to create not only vaadin web applications, but add-ons and touchkit projects, all of them based on maven.
and third, the hints and fixes that the editor shows when you are coding custom vaadin components. for example, netbeans will show a hint to create a state class when a connector does not override the getstate() method. very convenient.
anything else you want to share?
i would say that netbeans is a really strong option if you are planning to develop vaadin applications using maven. moreover, this is true for other technologies as well. i really like netbeans support for java 8, jpa, and javafx when compared to other ides!
thanks for taking this interview, alejandro!
Opinions expressed by DZone contributors are their own.
Trending
-
Comparing Cloud Hosting vs. Self Hosting
-
Operator Overloading in Java
-
Mastering Time Series Analysis: Techniques, Models, and Strategies
-
Competing Consumers With Spring Boot and Hazelcast
Comments