What Is New in JSF 4.1
JSF 4.1 delivers incremental improvements focused on alignment with Jakarta EE 11, enhanced component functionality, and developer experience refinements.
| Category | Key Changes |
|---|---|
| New Features | New h:element component, jakarta.faces.ALWAYS_FORCE_SESSION_CREATION
context param, UIComponent.getAttributes() default method. |
| Improvements | Enhanced h:selectManyCheckbox layout, f:ajax listener parameter support,
CDI alignment for converters/validators. |
| Bug Fixes | Resolved issues with state saving, view building, and component rendering. |
| Deprecations | Deprecated legacy javax.faces artifact coordinates and specific legacy methods. |
What are the new components and context parameters?
The main addition is the h:element component for generating arbitrary HTML elements. This gives
developers more flexibility when building views without needing custom components.
A significant new context parameter, jakarta.faces.ALWAYS_FORCE_SESSION_CREATION, allows you to
control session creation behavior for improved state management predictability.
The UIComponent interface also got a new default method, getAttributes(), which
provides a more convenient way to access a component's attribute map.
How have existing components been improved?
The h:selectManyCheckbox component now supports a new layout attribute. You can set it
to "spread" to prevent the checkboxes from being wrapped in a table, giving you more control over the rendered
HTML structure.
For f:ajax, you can now directly pass parameters to the listener method. This simplifies the code by
eliminating the need to stash parameters in the view scope before an AJAX request.
These changes are about providing more options and reducing boilerplate code for common tasks.
What changes were made for CDI and Jakarta EE 11?
JSF 4.1 tightens its integration with CDI. The specification now explicitly requires that converters and validators be CDI-managed beans when used in a CDI environment. This ensures consistency in dependency injection and lifecycle management across your application.
The release also includes necessary updates to fully align with the Jakarta EE 11 platform, ensuring compatibility and allowing you to use JSF with the latest Jakarta APIs.
What has been deprecated for removal?
The old javax.faces:javax.faces-api Maven coordinates are now officially deprecated. You should
update your dependencies to use jakarta.faces:jakarta.faces-api.
Specific legacy methods within the JSF API have also been marked for removal in a future release, signaling a continued move towards the modernized Jakarta EE namespace and APIs.
FAQ
Do I need to change my code for JSF 4.1?
Most existing applications will run without changes.
The main action item is to update your Maven dependencies from javax.faces to
jakarta.faces if you haven't already.
When should I use the new h:element component?
Use h:element when you need to
generate a specific HTML element that doesn't have a dedicated JSF component, like a <div> or
<span>, while still needing to leverage JSF's attribute and passthrough support.
What does the new ALWAYS_FORCE_SESSION_CREATION parameter do?
This context parameter ensures
a HTTP session is always created before the JSF lifecycle begins. This matters for applications that rely on
session existence for state saving or other logic, making the behavior more predictable.
Are my custom converters and validators now CDI beans?
If you are running in a CDI
environment, the specification now expects them to be. You should annotate your converter and validator classes
with appropriate CDI scope annotations to ensure proper injection and lifecycle.
Is the layout="spread" attribute for selectManyCheckbox a breaking change?
No, it's an
additive feature. The default layout behavior remains unchanged. You must explicitly set
layout="spread" to get the new non-table rendering.