Sergio
Sergio

Reputation: 3387

JSF 2 DI vs CDI Java EE 6/7

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?

Upvotes: 1

Views: 509

Answers (2)

John Ament
John Ament

Reputation: 11723

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.

Upvotes: 3

DNL
DNL

Reputation: 35

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.

Upvotes: 1

Related Questions