Tuesday, June 11, 2013

OmniFaces 1.5 is released!

OmniFaces 1.5 has been released!

Along a bunch new EL functions, new tag attributes, new utility methods and new converters there are 2 new major additions: 1) specifying JSF and HTML code as output format parameter; 2) escapable faces messages, targeting multiple components for messages and markupless rendering of messages.

Specifying JSF and HTML code as output format parameter

You'll probably recognize yourself in this:


general.contact = contact us
some.paragraph = Please <a href="{0}">{1}</a> for more information.

with


<h:outputFormat value="#{text['some.paragraph']}" escape="false">
    <f:param value="#{request.contextPath}/contact.xhtml" />
    <f:param value="#{text['general.contact']}" />
</h:outputFormat>

The resource bundle file is polluted with HTML code. This is not very maintenance friendly and the translator responsible for translating and maintaining the bundle files probably doesn't know anything about HTML. Also, you as developer don't have the possibility to use the JSF <h:link>, so you're forced to use a plain HTML <a> element (which doesn't understand JSF implicit navigation nor context root, so you've to specify the full URL as well).

With OmniFaces 1.5, the in OmniFaces 1.4 introduced <o:param>, will have new support for JSF and HTML code as children. This way it's possible to achieve the following:


general.contact = contact us
some.paragraph = Please {0} for more information.

with


<h:outputFormat value="#{text['some.paragraph']}" escape="false">
    <o:param><h:link outcome="contact" value="#{text['general.contact']}" /></o:param>
</h:outputFormat>

Escapable faces messages, targeting multiple components for messages and markupless rendering of messages

The standard JSF <h:messages> has been extended into <o:messages> with the following new features:

  • Possibility to specify multiple client IDs space separated in the for attribute.
  • Control HTML escaping by the new escape attribute.
  • Control iteration markup fully by the new var attribute which sets the current FacesMessage in the request scope and disables the default table/list rendering.

Particularly being able to use HTML in faces messages is a rather commonly seen/heard requirement. With the escape="false" it's now possible to use HTML in faces messages.


<o:messages escape="false" />

Beware of XSS attack implications when you're about to inline user-controlled input in such a message!

An overview of all additions/changes/bugfixes in OmniFaces 1.5

Taken over from the What's new? page on showcase:

Added in OmniFaces 1.5

  • Decode UIComponent children in <o:param> when no value attribute is specified (so that you can specify JSF/HTML code as outputFormat parameter)
  • Allow endusers to specify custom passthrough attributes for Html5RenderKit
  • Added new includeRequestParams attribute to <o:form>
  • <o:messages> which extends <h:messages> with support for multiple client IDs in for attribute, ability to disable HTML escaping and ability to perform markupless rendering like <ui:repeat>
  • Components#includeCompositeComponent() to programmatically include a composite component in given parent component
  • Add list based alternatives for the converters that automatically convert based on select items: omnifaces.ListIndexConverter and omnifaces.ListConverter
  • Message interpolator for Bean Validation that allows a component's label to be inserted in the middle of a message
  • New Faces#getRequestURLWithQueryString() which returns full request URL with query string
  • Added reset attribute to <o:cache> as an alternative for the programmatic resetting of a cache entry
  • Added converters for an Iterable to List and DataModel, so these can be used in <ui:repeat> and <h:dataTable>
  • New protected methods FullAjaxExceptionHandler#findExceptionRootCause() and #findErrorPageLocation() so that it can easier be subclassed
  • EL functions of:toJson(), of:replaceAll() and of:matches()

Changed in OmniFaces 1.5

  • Obtain current component via UIComponent#getCurrentComponent() when it's null in Html5RenderKit (so that it also works with PrimeFaces input components which for some reason send null as component argument)
  • Improved CallbackPhaseListener to support multiple callbacks instead of only one; the old Events#setCallbackXxx() methods are now deprecated
  • Support @all, @form and @this in Ajax#update()
  • Moved Faces#includeFacelet() to Components#includeFacelet(); the old one is now deprecated

Fixed in OmniFaces 1.5

  • Add missing createResource() overrides to all ResourceHandlers (so that it also works in combination with other resource handlers which don't use createResource(library, name))
  • Normalize view ID in RestorableViewHandler (so that it also works when another suffix mapping is used than *.xhtml, this worked in 1.3 but broke in 1.4 (sorry!))
  • Add missing support for noSelectionValue attribute in SelectItemsConverter
  • Action URL generation for FacesViews didn't take other view handlers into account, now it does (so that it also works with PrimeFaces 4.0 Dialog framework).

Maven download stats

Here are the Maven download stats:

  • March 2013: 2137
  • April 2013: 1995
  • May 2013: 2089

Here's a screenshot of the graph at Maven central:

3 comments:

edburns said...

Hello Bauke,

I would like to contact you via email. If you are open to that, please send me an email to edward dot burns at oracle dot com.

Thanks,

Ed

John said...

Excuse me Bauke, I don't know where to post this: The omnifaces showcase server is shutdown.

I hope this information can help you

Bauke Scholtz said...

@John: To me, both current and snapshot showcases are up and running.