One question left: where to put the code that does the redirect? At first I
put it in the method that processes clicks on the "logout" button, but of
course that threw an IllegalStateException.

So I thought I'd put it in the beforePhase method of a PhaseListener
listening for PhaseId.RENDER_RESPONSE events. That resulted in an exception
I don't understand: 

java.lang.NullPointerException
        at
javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:929)


And Tomcat prints out:

SEVERE: Faces context not found. getResponseWriter will fail. Check if the
Faces Servlet has been initialized at all in your web.xml. 

So it looks as if redirecting at that point completely loses the
FacesContext.

So where (and when) would ExternalContext.redirect actually work?

And doesn't this seem like a lot of trouble to go through to do something
that would be trivial using any other web application development framework?
Or even no framework at all?

Steven Gollery




Simon Kitching-3 wrote:
> 
> Well, you can use a managed bean property to define the url to redirect 
> to. Agreed it's not as nice as having it with the rest of the navigation 
> rules, but at least it's not hard-coded.
> 
> Steven Gollery wrote:
>> Yes, that should work. Of course it also hardwires the page navigation
>> into
>> the source code, but I guess I'll have to live with that.
>>
>> Thanks,
>>
>> Steven Gollery
>>
>>
>> Simon Kitching-3 wrote:
>>   
>>> Hi Steven,
>>>
>>> I believe you can bypass navigation rules by doing this in an action
>>> method:
>>>   facesContext.getExternalContext.().redirect(url);
>>>     
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/leaving-https-tf2570694.html#a7250379
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to