I'm trying to add parameters for a PhaseListener to intercept after an action method is executed and redirected to another page - what is the best way to do this?
- explicit
redirect
call and wrap the additional parameters withPrettyFacesWrappedRequest
? - using
flash
scope on both ends (caller bean and phase listenerafterPhase
)?
Which version of JSF are you using?. With JSF 2.0, 2.1 or 2.2 you can use CDI beans and use interceptors for change the return of your method.
I don't believe that changing JSF Lifecycle becauase of yor Business Logic is a good idea.
You may use interceptors. For example
index.xhtml
Then your CDI Interceptor Intercept FacesContext and HttpServletRequest (you can use any of them):
And finally you use "HttpServletRequest" in your CDI controller for analyze HTTP servlet request, and even you can use'it for put request Attributes.
In that way you can achieve redirection to another JSF Page, based on HTTP Servlet request.
You may remember enable CDI Interceptors in beans.xml
UPDATE Interceptors are used for Cross-Cutting concerns, so you use it when you have to apply it to more than one method. If every method has your own logic in your interception, you may use Decorators.