Blog

Vaadin Framework 8.4 coming out with a bunch of enhancements and improved JDK 10 support

By  
Matti Tahvonen
Matti Tahvonen
·
On Apr 6, 2018 5:30:00 AM
·

Update: Vaadin Framework 8.4.0 is now available.

Alpha releases of Vaadin 8.4 are already available, and the final is scheduled for the 25th of April. The feature release contains enhancements to Grid, TreeGrid, Binder, converters, DateField, BrowserResizeListener and more.

  • ComboBox has a better handling of new items with NewItemProvider.
  • Binding API has been improved to allow more advanced usage.
  • New ReadOnlyHasValue wrapper helps to bind any visible element to a data item via Binder.
  • Built-in StringTo converters now have an option to use ErrorMessageProvider.
  • Grid headers and footers now support tooltips.
  • Added Tree and TreeGrid recursive expand and collapse methods.
  • BrowserResizeListener is called lazily during the resize (previously on each and every event browser fired, causing potentially hundreds of server visits per window resize).
  • ItemClickEvent for Grid now takes an additional row index parameter.
  • Support starting downloads and opening URLs from a menu item.

To see the full list of changes, refer to release notes or change history in GitHub.

JDK 10 is here, Vaadin is ready!

JDK 10 was released recently, and Vaadin is ready. Vaadin 8.4 brings full support for the latest and greatest JDK.

From a developers point of view, the var keyword is probably the most exciting feature. With it, certain expressions become much more compact, and more readable - but only if you use proper naming of variables. Here are some simple examples of how it can affect your code:

   var nameField = new TextField();
   // previously: TextField nameField = new TextField();
   
   var strToInt = new HashMap<String,Integer>();
  // previously: Map<String,Integer> strToInt = new HashMap<String,Integer>();

You can actually also use JDK 10 and Java 10 features with the 8.3 series. There are no compatibility changes needed to the core libraries or tooling. The JDK 10 support in Vaadin 8.4 is just updating certain plugins in our archetypes, so that they now work out of the box with JDK 10, as well.

Configuring your web server, Maven build and IDE to work with Java 10

To actually start using Java 10 features in your Vaadin application, you’ll still need to change your project to compile Java 10 source code. Another annoyance is that there are certain libraries and application servers that don’t yet work out of the box with Java 10. Also, the IDE support is still not very good, but Eclipse nightlies and the latest commercial version of IntelliJ works with Java 10.

But as you are for sure enthusiastic about getting the latest and greatest stable Java version, here is how to do it, starting on our vaadin-archetype-application.

First, you’ll need to configure your pom.xml to use JDK 10:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.7.0</version>
  <configuration>
    <release>10</release>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <version>6.1</version> <!-- Use newer version of ASM -->
    </dependency>
  </dependencies>
</plugin>

You can also get rid of the following properties that define the source and target levels, which currently default to 8:

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

To get your application tested on the Jetty, we’ll need a small hack. Jetty uses the popular ASM library and a version of it, which is not yet compatible with Java 10. To workaround that, we’ll override the ASM version to the latest and you can then run your first Vaadin app with Java 10 with a simple “mvn jetty:run” command:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.4.8.v20171121</version>
  <configuration>
    <scanIntervalSeconds>2</scanIntervalSeconds>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <version>6.1</version> <!-- Use newer version of ASM -->
    </dependency>
  </dependencies>
</plugin>

If you just rather check out a working Java 10 + Vaadin project to start playing with JDK 10, you can also check out my test app from Github.

Try Vaadin Framework 8.4.0.rc1

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