I want to use the @ViewScoped
- scope in my application for the backing beans of some web pages. Also I use CDI to inject the dependecies into the backing beans.
However, when I use a backing bean annotated like this
@ManagedBean
@ViewScoped
@Inject
someDependency (...)
the @Inject
annotation will not inject anything and i get a NullPointerException
as soon as i am accessing the dependency.
However, when I decorate the backing bean with
@Named
@ViewScoped
@Inject
someDependency (...)
the injection works fine, but now the @ViewScoped
is ignored as it is not part of CDI / Weld.
How can I use @ViewScoped
together with CDI Weld?
No, it's not directly supported. Seam3 is supposed to provide such extras that CDI does not. Check it out.