Considering that JSF2 provides you no injection support for FacesContext
, it seems like there may be a bigger question at play. I believe JSF 2.2 added support for this via @Inject
. Managed properties cannot be injected, the expected equivalent is to provide a @Named
bean with getters and setters properly defined and leverage that from the UI.
JSF 2 DI vs CDI Java EE 6/7
-
02-10-2022 - |
Question
How different is JSF DI from CDI? I mean, is possible to inject all the things that we use with JSF DI (such as FacesContext
, managed properties, etc.) with the CDI spec? There are issues or pitfalls?
Solution
OTHER TIPS
There are no issues, you can inject CDI beans into JSF Managed Beans or use directly. I heard that JSF DI will be replaced by CDI in future Java EE releases. You can have everything in Spring IoC container instead.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow