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?

Was it helpful?

Solution

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.

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
scroll top