OmniFaces 2.0 released!
OmniFaces 2.0 is a direct continuation of OmniFaces 1.x, but has started to build on newer dependencies. We also took the opportunity to do a little refactoring here and there (specifically noticeable in the Events class).
The easiest way to use OmniFaces is via Maven by adding the following to pom.xml:
<dependency> <groupId>org.omnifaces</groupId> <artifactId>omnifaces</artifactId> <version>2.0</version> </dependency>
A detailed description of the biggest items of this release can be found on the blog of BalusC.
One particular new feature not mentioned there is a new capability that has been added to <o:validateBean>; class level bean validation. While JSF core and OmniFaces both have had a validateBean for some time, one thing it curiously did not do despite its name is actually validating a bean. Instead, those existing versions just controlled various aspects of bean validation. Bean validation itself was then only applied to individual properties of a bean, namely those ones that were bound to input components.
With OmniFaces 2.0 it's now possible to specify that a bean should be validated at the class level. The following gives an example of this:
<h:inputText value="#{bean.product.item}" /> <h:inputText value="#{bean.product.order}" /> <o:validateBean value="#{bean.product}" validationGroups="com.example.MyGroup" />
Using the existing bean validation integration of JSF, only product.item and product.order can be validated, since these are the properties that are directly bound to an input component. Using <o:validateBean> the product itself can be validated as well, and this will happen at the right place in the JSF lifecycle. The right place in the lifecycle means that it will be in the "process validation" phase. True to the way JSF works, if validation fails the actual model will not be updated. In order to prevent this update class level bean validation will be performed on a copy of the actual product (with a plug-in structure to chose between multiple ways to copy the model object).
More information about this class level bean validation can be found on the associated showcase page. A complete overview of all thats new can be found on the what's new page.
Arjan Tijms
Comments
Post a Comment