Tuesday, November 04, 2014

Building and Testing JSF.next

The JSF 2.3 Expert Group is hard at work determining which features will be part of the upcoming release.  The JSF Team been working hard improving CDI alignment, among other things.  There are already a number of new features in the JSF 2.3 codebase that you can begin to test.  I will attempt to keep this post updated with the latest features that have been added.  For the most up-to-date reference, please see Manfred's blog.  To reference the information from Manfred's blog, take a look here.

JSF 2.3 Features

**Updated 04/2015:

 - PostRenderViewEvent added, which is published immediately after a view is rendered

    <f:event type="postRenderView" listener="#{managedBean.doPostProcessing}" />

 - Support java.lang.Iterable in UIData and UIRepeat
 - Support for java.util.Map in UIData and UIRepeat
 - Facelets hot reload will be off by default.
   In JSF 2.2 and prior, Facelets were set to refresh the cache periodically by default.
 - Injection into the following artifacts:
  •     javax.faces.convert.Converter
  •     javax.faces.validator.Validator
  •     javax.faces.component.behavior.Behavior
Arjan Tijms explains the enhancements for CDI injection and resolving of EL artifacts very well in his post on JSF 2.3.  
Below, I list the default producers that are part of JSF 2.3.  
(As per Arjan Tijms post:  What's New in JSF 2.3?)

In order to facilitate CDI injection, there will be default producers for the following:
  •  ViewRoot
  •  ViewMap (@ViewMap)
  •  RequestCookieMap (@RequestCookieMap)
  •  SessionMap (@SessionMap)
  •  ApplicationMap (@ApplicationMap)
  •  FacesContext
  •  ExternalContext
- CDI managed validator:
  @FacesValidator(value = "myValidator", managed = true)
  public class MyValidator implements Validator {
     MyModel model;
- CDI managed converter:
  @FacesConverter(value = "myConverter", managed = true)
  public class MyConverter implements Converter {
The features that have been added as of 11/4/2014 are as follows: - Inject @ViewMap
Map viewMap;
- #1333 - Support @Inject for UIViewRoot

UIViewRoot viewRoot;
- #1332 - Let CDI handle #{view}
- #1331 - Let CDI handle #{application}
- #1254 - contracts attribute too restrictive.
- #1328 - Let CDI handle #{session} EL resolving
- #1325 - Let CDI handle #{applicationScope}
- #1311 - Let CDI handle #{facesContext} EL resolving
- #1323 - Support @Inject for the applicationMap

Map applicationMap;
- #1322 - Simplify #{externalContext} to use ExternalContextProducer
- #1309 - Support @Inject for ExternalContext

@Inject ExternalContext externalContext;
- #527 - Support @Inject for FacesContext

 @Inject FacesContext facesContext;
Please reference the JavaServer Faces JIRA for more information.

  * Be sure to test against one of the milestone releases before placing JIRA issues.

  Taking JSF 2.3 for a Test Spin

 If you would like to start testing out these new features today, the easiest way to get started is to simply download the 2.3 SNAPSHOT and then replace the javax.faces.jar file within your GlassFish/glassfish/modules directory with the snapshot. You will need to be sure to reference version 2.3 in your faces-config.xml. as follows:
<faces-config  version="2.3"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd">

If you are adventurous and you would like to build JSF from source, that is also fairly simple.  To do so, follow these steps:
 1)  Clone the trunk using Git: git clone https://github.com/javaserverfaces/mojarra.git
(Old Repository Path: Check out the trunk using SVN: svn checkout --username yourname --password x https://svn.java.net/svn/mojarra~svn/trunk)
 2)  Copy the build.properties.glassfish file to build.properties
 3)  Edit the build.properties file and set jsf.build.home to your source home.
 4)  From the source home, run ant clean main The jsf-api.jar will be in SOURCE_HOME/jsf-api/build/lib and jsf-impl.jar will be in SOURCE_HOME/jsf-ri/build/lib

For more information on building the sources (and even contributing), please see the following reference: https://wikis.oracle.com/display/GlassFish/JavaServerFacesRI#JavaServerFacesRI-HowcanIcontribute%3F


  1. Manfred6:51 PM


    You should be able to use the 2.3 schema as per usual.
    The Mojarra runtime contains its own copy of it in the jar.


  2. I am updating the sample code accordingly...thanks Manfred!


Please leave a comment...