Flow - are you using Polymer templates or Java code for your views?

Curious to hear feedback from those of who have worked with V10/11.

Do you use Polymer templates or Java code to create your views? And why?

The reason for my question is that in the 5 months I’ve been using V10/11, the vast majority of the issues I’ve experienced were related to Polymer templates and/or ID bound fields. A few examples:

  • FormItem can’t be used in Polymer templates. Designer incorrect marks it as an element. Changing the Element to a FormItem causes exceptions at runtime. Creating the FormItem in Java code works fine.
  • Tabs in 11 beta 2 & 3 are broken when used in Polymer templates. Creating tabs in Java code works fine.
  • When using Polymer Checkboxes and Radiobuttens with a binder, the field value is reset when the view loads. Creating checkboxes and Radionbuttens in Java code works just fine, even when used with a binder.

Defining viwes in the designer is a big help. I’ve heard from Vaadin that Polymer templates performs better than Java code (disclaimer: I haven’t validated this myself nor how big the difference is is). That being said, my experince is that codoing the entire view in Java results in few issues.

What’s your experience?

I’m new to Vaadin - currently looking at it as a replacement platform for our suite of applications and will only consider Flow, nothing older.

I began by looking at the sample applications, working through some exercises and using the Designer tool for the template approach. I was able to get a small proof of concept application up and running against our database (using only JDBC - prefer to stay away from any sort of data persistence (JPA) in order to re-use as much of our existing code as possible). Had trouble getting lists (grids) to update when making a change to a record and not sure how to get grid lazy loading to work without using JPA - (which may also be the problem with the grid updates?)

With those troubles, I admittedly stepped away and started looking at some other options (which I was going to do anyways), until my colleague found Alejandro Duarte’s book Data-Centric Applications with Vaadin 8. This book helped check off a few of the items we need to replace or improve upon in our migration to a new platform, and does so with the Java approach (except lazy loading is achieved with JPA). I got further along on a new Java-based proof of concept by working through the book and am more excited with this approach, though my impression is that the Java approach isn’t the generally preferred way to go with Vaadin Flow… Is that correct? I’ll need to do more reading on the subject.

Writing UI code in Java is still a completely valid approach. It’s true that many new examples showcase Polymer templates, as that’s the cool new client-side implementation technology, but using them is not an end by itself, they’re just one way of getting the job done.

The benefit of Polymer templates is that they’re a powerful and flexible way of integrating the server to the client in ways that the developers of the components might not have anticipated. The benefit of writing UI code in Java is that it’s (mostly) easy to understand even if you don’t want to get into the details of the client-side implementation, and connecting to Java libraries and services is straightforward. The more you need to customize the UI functionality to your specific needs, the more you will gain from using templates, but there’s nothing stopping you from creating a template component here and there while writing most of the application in plain old Java code.

Thanks Olli