OmniFaces 2.1 has been released!
This version brings relatively more enhancements and fixes than really new things. Among others, the code base has been thoroughly tested with serialized view state turned on (as in javax.faces.SERIALIZE_SERVER_STATE=true
, which is new since JSF 2.2) and fixed where needed. And, the code base was inspected with Sonar and as much as possible warnings were fixed, hereby even further improving the quality of the code base. Also, the Javadocs have been reviewed and improved where possible. Further, all resource handlers (combined resource handler, unmapped resource handler, CDN resource handler and graphic image resource handler) have been reworked to be better compatible with other JSF component libraries (like PrimeFaces and PrimeFaces Extensions, which were using only one or two of the three available createResource()
methods). Finally, the CDI detection has been altered to be better compatible with Tomcat + OpenWebBeans.
As usual, in the What's new page of the showcase site you can find an overview of all what's been added/changed/fixed for 2.1. The top three additions are the brand new @Cookie
annotation, improved SVG support by <o:graphicImage>
component and support for server side caching in CombinedResourceHandler
.
Oh, we finally got a new logo too. The old logo, basically a buckminsterfullerene in pentagon projection, was not really scalable. Now just a cyclopentane is extracted from it. You can see it on the header of the showcase. For fans, the full logo is also available in SVG format here.
Installation
Non-Maven users: download OmniFaces 2.1 JAR and drop it in /WEB-INF/lib
the usual way, replacing the older version if any.
Maven users: use <version>2.1</version>
.
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.1</version>
</dependency>
For users who don't want to use CDI, there's the 1.11 with all 2.1 enhancements and fixes (but no brand new additions!).
Inject cookies via CDI
This is actually a really trivial addition. Just a new annotation and only 3 lines of hard work in the producer class.
Normally, with JSF managed beans as managed by @ManagedBean
, you would be able to inject the value of a cookie with name "foo"
via @ManagedProperty
as below:
@ManagedProperty("#{cookie.foo.value}")
private String foo;
However, this possibility has disappeared when switching to CDI managed beans as managed by @Named
. OmniFaces therefore injects a @Cookie
in its CDI assortiment.
@Inject @Cookie
private String foo;
Here, the property name foo
will by default be used as cookie name, like as how @Param
already works.
Improved SVG support in <o:graphicImage>
The <o:graphicImage>
, new since OmniFaces 2.0, has been enhanced to better support SVG images, including SVG view mode support via fragment
attribute (i.e. being able to show only specific sections of a SVG image).
<o:graphicImage name="some.svg" fragment="svgView(viewBox(0,50,200,200))" />
Server side caching in CombinedResourceHandler
Thanks to inspiration and contributions of Stephan Rauh (from beyondjava.net, AngularFaces and BootsFaces), it's now possible to let CombinedResourceHandler
cache the combined resources in server memory without the need to read/combine them from source again and again.
To turn on it, just set the org.omnifaces.COMBINED_RESOURCE_HANDLER_CACHE_TTL
context param with a value bigger than 0
, indicating the "cache time to live" in seconds (i.e. cache will be purged after X seconds). Here's an example assuming you'd like to cache them for 1 day (86400 seconds):
<context-param>
<param-name>org.omnifaces.COMBINED_RESOURCE_HANDLER_CACHE_TTL</param-name>
<param-value>86400</param-value>
</context-param>
See also Stephan's blog on the subject.
Maven download stats
Here are the Maven download stats:
- November 2014: 4444
- December 2014: 5081
- January 2015: 5837
- February 2015: 4985
- March 2015: 5303
- April 2015: 5749
- May 2015: 5995
Below is the version pie of May 2015:
Surprising how many <=1.8.1 users are still there. To those who can't upgrade to 2.1 or 1.11, I'd like to point out that 1.8.3 contains an important memory leak fix in case you're using UnmappedResourceHandler
while having composite components on the pages. So, if you can't upgrade to 2.1 or 1.11, then at least upgrade to 1.8.3.