Errai: The browser as a platform

Tuesday, November 7, 2017

Errai 4.1.0.Final Released

We've recently released Errai 4.1.0.Final, the first release on master since branching off the 4.0.x series. In this short post, I will highlight some of cool new things you can find in 4.1.0.Final, which include:
  • Size and performance improvements in code generated for Errai Marshalling and Errai Data Binding
  • Custom content delegation in Errai Navigation
  • moved to META-INF
  • Templating and Data Binding support for Elemental 2
The best part: two of these changes were delivered by our fantastic community. Read below for descriptions about these features. At the end I will talk briefly about forward-development currently happening in Errai.

Marshalling and Data Binding Improvments

Both Errai Marshalling and Data Binding use generated code to introspect and access members of annotated classes. In Errai 4.1.0.Final, this code has been refactored to decrease generated code size and better take advantage of optimisations for String literals in the GWT compiler.

If you use Errai Marshalling or Data Binding heavily, Errai 4.1.0.Final should noticeably decrease the size of your JavaScript payload. A big shout out to slavap for this excellent contribution!

Custom Content Delegation

Errai Navigation provides lots of page-specific mechanisms for hooking into the navigation lifecycle, but until now there were no convenient ways to generically customize how all pages were shown or hidden.

Errai 4.1.0.Final introduces a content delegation system. Users can override a ContentDelegation interface and replace the default implementation to insert their own custom logic for displaying and hiding all pages. The delegation is quite flexible, even allowing for asynchronous actions.

A big thanks to BenDol for the concept and implementation of this feature!

Configuration Moved to META-INF

By convention, configuration files that don't require name-spacing are supposed to be placed in the META-INF folder. Errai 4.1.0.Final supports scanning files in the META-INF folder, allowing users to follow this convention. Moving forward, you should consider this a best practice.

Errai 4.1.0.Final will still work properly with files outside of a META-INF folder, but you may see an abundance of warnings in your logs, as we will likely phase out support for this in our next major release.

Elemental 2 Support for Templating and Data Binding

Elemental 2 is a project that exposes built-in web APIs in Java. Like the first Elemental, the project is automatically generated from external definitions of web APIs. Unlike its predecessor, Elemental 2 uses JS Interop.

Back when we began work on Errai 4, Elemental 2 was not yet available. We didn't want that to slow down our work on HTMLElement-based user interfaces and JS Interop support, and so we created a collection of hand-written element wrappers in Errai.

But now that Elemental 2 is available, it is in the best interests of the GWT community to standardise around these. As such, Errai's DOM wrappers have been deprecated and we have added full support to templating and data-binding for classes from Elemental 2.

We will not be removing the Errai element wrappers, but we will also not be updating them, and you are highly encouraged to use Elemental 2 going forward.

Looking to the Future

The biggest priority for Errai in the coming months is preparing for migration to GWT 3. We've known for some time that GWT 3 will require big changes to the way we develop GWT applications. There probably won't be GWT Widgets. There definitely won't be GWT Generators.

We've already made large strides towards GWT-Widget-less UI development. Although there is some more work to be done here, we are also beginning progress on the even larger and equally important task: migrating Errai's GWT generators to annotation processors.

I'd like to take this opportunity to mention recent addition to our team, Tiago Bento, who has been the driving force behind our APT migration efforts. It's not quite ready for a test drive yet, but keep an eye out in the future for blog posts about how to try out Errai annotation processors on our snapshot releases.

Until the next time, happy coding!