In a JSF project, we wrote our own PartialViewContext to listen to some events fired by pages beans:
@RequestScoped
public class OurPartialViewContext extends PartialViewContextWrapper
{
...
// called by cdi
@SuppressWarnings("unused")
private void listenForUpdate(@Observes OurRefreshEvent event)
{
...
And we wrote the matching factory, injecting it:
public class OurPartialViewContextFactory extends PartialViewContextFactory
{
@Inject
private OurPartialViewContext customPartialViewContext;
...
Problem is that in the newest versions of JSF, the empty constructor for PartialViewContextWrapper is deprecated, asking us to use another constructor with the wrapped object in parameter.
Currently, our PartialViewContext needs to be tied to the request scope, in order to be modified during the request by the observed events and to be used by a custom PartialResponseWriter we also wrote.
So our PartialViewContext currently both:
- must have an empty constructor, as it is a
@RequestScopedbean; - should not have an empty constructor, as it is deprecated for
PartialViewContextWrapperwhich it inherits from.
How could we find a solution there?
We tried to remove it from the scope and build it in the Factory with a simple new OurPartialViewContext(), but then the @Observes methods are never called.