CDI compatible @ManagedProperty
Last updated
Was this helpful?
Last updated
Was this helpful?
In JSF 2.3, the built-in scope annotations are deprecated, there are some alternatives provided in CDI, eg. ApplicationScoped
, SessionScope
, RequestScoped
, etc.
In JSF 2.2, JSF itself provided a CDI compatible ViewScoped
, to view more details.
There is an exception, we can not find an alternative for the legacy @ManagedProperty
, there is a describe how to created a CDI compatible @ManagedProperty
from scratch.
Fortunately, JSF 2.3 provides a built-in CDI implementation.
Let's create a sample to try it.
Create a simple backing bean.
NOTE, @ManagedProperty
is from package javax.faces.annotation
, which is newly added in JSF 2.3.
fooBean
is a CDI bean, which has a property named bar
.
In the facelets template, display the message of BackingBean
.
Run this application on Glassfish v5, open your browser and navigate to .
Grab the from my GitHub account, and have a try.