Saturday, July 18, 2020

OmniFaces 4.0-M1 ready for testing!

This is the first milestone release of OmniFaces 4.0, which is the first version developed specifically for JSF 3.0 from Jakarta EE 9 which is currently scheduled to be released at September 2020! OmniFaces 4.x is NOT backwards compatible with earlier Java EE / JSF versions because of the migration of the javax.* package to jakarta.* package.

Noted should be that Jakarta EE 9 initially went for Java 11 as minimum Java version, as can be seen in pom.xml of RC1, but this was unfortunately since RC2 switched back to Java 1.8 due to time constraints. Hence OmniFaces 4.0 is also still at Java 1.8.

The integration tests currently run successfully on GlassFish 6.0.0.M1.

Breaking changes:

  • Obviously, the migration from javax.* package to jakarta.* package. E.g. javax.faces.context.FacesContext is now available at jakarta.faces.context.FacesContext. This is however a general change in Jakarta EE itself. Jakarta EE 8 did still use the javax.* package, but Jakarta EE 9 uses now its own jakarta.* package. OmniFaces own package org.omnifaces.* is still the same as it is.
  • The date beans #{now} and #{startup} have been migrated from java.util.Date to java.time.Instant. This means that e.g. #{now.time} does now not work anymore as the java.time.Instant does not have a getTime() method. EL 4.0 will throw the following exception:
    jakarta.el.ELException: /test.xhtml: The class 'java.time.Instant' does not have the property 'time'.
    Sorry about that, but it was high time to migrate to the much better java.time API! You need to modify your JSF files to catch up this. Use e.g. #{now.epochSecond}, #{now.nano}, or #{now.toEpochMilli()} instead.
    UPDATE: as per the upcoming 4.0-M2 these will continue supporting #{now.time} format! And additionally these will offer #{now.instant} and #{now.zonedDateTime} properties to give you concrete instances of java.time.Instant and java.time.ZonedDateTime.
  • The <o:form includeViewParams="true"> which was deprecated since 3.0 has now been removed because this is already the default behavior.
  • The WebXml.INSTANCE and FacesConfigXml.INSTANCE which were deprecated since 3.1 have now been removed. Use WebXml.instance() and FacesConfigXml.instance() instead. This was done because they can then be @Inject'ed in a CDI bean.
  • The script omnifaces:fixviewstate.js which was deprecated since 3.0 has now been removed. This script is unnecessary since JSF 2.2 as it was fixed over there.

No new things are added, so the existing features are basically the same as with the current 3.7.1 version. JSF 3.0 itself is technically also basically the same as JSF 2.3, except for the change of the package from javax.faces.* to jakarta.faces.*. In other words, it has just been 'jakartified' ;)

Also note that the showcase still runs 3.7.1 (for now). Once WildFly comes with a final JEE9 version, it'll be updated over there as well.

Installation

Non-Maven users: download OmniFaces 4.0-M1 JAR and drop it in /WEB-INF/lib the usual way, replacing the older version if any.

Maven users: use <version>4.0-M1</version>.

<dependency>
    <groupId>org.omnifaces</groupId>
    <artifactId>omnifaces</artifactId>
    <version>4.0-M1</version>
</dependency>

If you have found any issues or comments related to OmniFaces 4.0, please by all means report an issue.

Migration of your project from Java EE 8 / Jakarta EE 8 to Jakarta EE 9

Use this dependency (note: keep an eye on newer RC/M versions and bump accordingly):

<dependency>
    <groupId>jakarta.platform</groupId>
    <artifactId>jakarta.jakartaee-api</artifactId>
    <version>9.0.0-RC2</version>
    <scope>provided</scope>
</dependency>

Then it's really basically a matter of performing a find&replace of the literal string "javax." to "jakarta." throughout the entire project! Perhaps a few things will not compile because they are still javax.*, but it's a matter of renaming them back, which you can then do a bit more specific. For example, javax.xml.* and javax.sql.* are still in Java SE. You should then find&replace e.g. the "jakarta.xml." back to "javax.xml.". Oh, don't forget to rename the files in META-INF/services, if any ;)

No comments: