Reply To: Cannot inject path parameter in @ViewScoped Bean

Splash Forums Rewrite Users Cannot inject path parameter in @ViewScoped Bean Reply To: Cannot inject path parameter in @ViewScoped Bean

#25219

You have to defer the binding of the parameter to get it to work correctly. That’s because by default Rewrite processes bindings very early during request processing, even before the JSF lifecycle starts. But if you defer the binding, it will be submitted after the JSF lifecycle started. Just add the @Deferred annotation to your parameter like this:

@Parameter
@Deferred
@Matches("[0-9]+")
private Long id;

I’m currently thinking about adding some kind of auto detection mechanism that automatically adds the deferral if the injection happens on a JSF bean (or a CDI bean with a JSF view scope) But that is still WIP. So for now you have to add the annotation manually.

BTW: You have to add rewrite-integration-faces for this to work correctly.