; last updated - 11 minutes read
Fork me on GitHubAngularFaces 2.1 is more than a bug fix release. It contains a couple of features I deliberately postponed in order to get a thoroughly tested version 2.0 out in times. The list below counts no less than 15 improvements. One of the improvements has nothing to the with code: I put AngularFaces 2.1 under an Apache V2 licence, which is much more liberal than the GPL licence of the previous version.

Examples and code snippets

Pictures say more than words, so let's start with a couple of screenshots and code snippets. Click the tabs to see the source codes.

ng-table is a great client-side datatable component written in AngularJS. Thus, it's a natural fit to AngularFaces.

Many business applications consist of long forms. AngularFaces simplifies writing such forms by adding labels and messages (including internationalization) automatically. If possible, it validates the form on the client, thus reducing the server load.

The JSF view below shows how to exchange arbitrary data between client and server using the new

tag.

How to use AngularFaces 2.1 with Maven

AngularFaces 2.1 is available on Maven Central. So you can download it directly from Maven Central, or you can add a dependency to your Maven pom.xml or your Gradle build file:

de.beyondjava angularFaces-core 2.1.0 ...

What's new in AngularFaces 2.1?

Describing every new feature of AngularFaces 2.1 in detail would make for a very long article. However, I'll mention every new feature briefly here, postponing the details of most features to follow-up articles. Follow the links to read the full story:

  • AngularFaces 2.1 is available under a liberal Apache V2 licence.
  • div and span tags are first class citizens of the JSF tree. This allows you to program almost the way you're used to from pure AngularJS applications.
  • The tag allows you to synchronize arbitrary data structures between server and client.
  • Optional caching reduces the amount of data sent to the client significantly.
  • Both Jackson and Google Gson are supported to serialize Java beans to Json objects. However, I postponed Moxy to AngularFaces 2.2.
  • AngularFaces reads bean validation annotations not only from the attribute, but also from the getter.
  • and are fully supported by AngularFaces.
  • AngularFaces 2.1 supports both Mojarra and Apache MyFaces.
  • It also contains special support for BootsFaces 0.6, which in turn is a JSF library that makes using Bootstrap in a JSF application a breeze.
  • Marco Rinck contributes his great JUA library to AngularFaces. JUA integrates JSF AJAX capabilities seamlessly into an AngularJS page.
  • Did you ever wonder why JSF integrates drop down menu (aka comboboxes) in such a clumsy way? I found a way to write selectOneMenu almost the way it's written in pure HTML pages.
  • AngularFaces 2.1 updated to AngularJS 1.3. Unfortunately, this is a potential source of incompatibilities. Luckily, it's almost the only such source. Everything else should migrate smoothly.
  • The CombinedResourceHandler of OmniFaces is supported. That's an important point because AngularFaces pages tend to deliver many Javascript files. Omnifaces boils these files down to a single file, which loads a lot faster than many small files.
  • The "automagical" generation of labels and messages and be configured much more flexible. Originally, you only could disable this feature on a per-page basis. Now it's possible to add the attributes addLabel="false" and addMessages="false" to every container object that's part of the JSF tree.
  • I simplified the tag.

: send arbitrary data to and from the client

The second most important new feature is . Now it works in both directions. Use the attribute "direction" to define whether you want a two-way synchronization or only a one-way synch:

AngularFaces also cares about network bandwidth optimization. If you're sure the values on the server never change it suffices to send the data only once to the AngularJS model. That's what's the once attribute is for:

The cacheable attributes reduces the amount of data send to the client significantly:

ngsync is used a lot in the car dealer demo.

Alternative Json serializer: Jackson

Another big ticket required only a few lines of code: AngularFaces 2.1 supports two JSON serializers. GSon was already supported by AngularFaces 2.0. Now it's accompanied by Jackson. Configuration is as simple as can be: you don't have to do anything. If Jackson's available, AngularFaces uses Jackson, if GSon's available, it uses Gson. Future versions of AngularFaces will also support other JSON frameworks, such as Moxy.

Bean validation annotation on getters

JSR303 bean attributes used to be read only from the field. Now AngularFaces also considers annotations of the getter. That's useful if there's no field, only a getter and a setter.

Global messages

Neither nor were updated in an AngularFaces 2.0 request (update="angular"). AngularFaces 2.1 now updates global error messages without further ado.

Internal changes: client side components and refactoring

A couple of components now are rendered on the client side: labels, error messages,

and . In general, client side widgets optimize network traffic and reduce the load on the server, which in turn results in a better user experience.

AngularFaces 2.1 has also seen of lot of refactoring under the bonnet. A couple of implementations in AngularFaces 2.0 felt like a hack to me, so I re-implemented them to make AngularFaces 2.1 more reliable, more future-proof and - as a bonus - even faster. Among other things, MyFaces stopped to complain about me polluting the session with non-serializable object.

Open tickets

There are a few open tickets left of AngularFaces 2.1: support of additional JSON serializers and making file resolution more flexible. AngularFaces doesn't cope with URL mappings such as

Faces Servlet myFavoritePath/*.jsf

How to get started? Template and demo projects

There's a very simple "Hello world" project on GitHub. A more ambitious project is a little Tetris clone. It shows how to use everything at once: Bootstrap (via BootsFaces), AngularJS, JSF and several hundred lines of Javascript code.

The car dealer demo explores most features of AngularFaces. There's a caveat: it's the project I use for experiments, so chances are the documentation needs to be improved.

Kudos and: Do you want to contribute?

Rudy de Busscher, Thomas Andraschko, Marco Rinck, Vitor Ximenes Fontenelle and a developer called Ratcashdev on GitHub helped to finish and polish AngularFaces 2.1. Thanks, everybody! Kudos also go to everyone who opened an issue on GitHub or dropped my a note. Your feedback matters!

By the way, contributions are always welcome. The simplest way is to report an issue on GitHub or to drop a note in the comments section below. To contribute code, you can fork AngularFaces on GitHub and create a pull request.

Version 2.2 and beyond

The next versions of AngularFaces probably won't deal with the core framework, but with additional features. In particular, I'd like to provide a widget library that's rendered on the client instead of sending vast amounts of HTML code from the server to the client. And of course I plan to add Dart / AngularDart support.

And then there are the wild ideas. Wouldn't it be nice to simply write

and have it converted automatically to a PrimeFaces ?


Dig deeper

AngularFaces.com - tutorial pages (still showing AngularFaces 2.0)

AngularFaces 2.1 announcement - part 1

AngularFaces GitHub repository

AngularFaces 2.0 announcement

AngularFaces 2.0 Embraces Both HTML5 and PrimeFaces

AngularFaces: AngularJS Puts JSF on Steroids


Comments