You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mike Duffy <md...@yahoo.com> on 2006/02/05 00:33:57 UTC

Tag Only Works Within a Request?

It seems that the <h:messages> tag only works within a request.  If something goes wrong on the
current page, the messages display fine. 

What I would like to be able to do is display a message on the next page (in a new request scope)
once the current page has processed.  I can't seem to get this to work.

Is there a session scope for the <h:messages>?

Am I missing something basic?

Thx.

Mike

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Tag Only Works Within a Request?

Posted by Mike Kienenberger <mk...@gmail.com>.
As long as you're not using a <redirect/> navigation case tag, you
should be able to do this without changes.

Otherwise, you'll want to take a look at

http://issues.apache.org/jira/browse/MYFACES-516

which has a number of different solutions.

On 2/4/06, Mike Duffy <md...@yahoo.com> wrote:
> It seems that the <h:messages> tag only works within a request.  If something goes wrong on the
> current page, the messages display fine.
>
> What I would like to be able to do is display a message on the next page (in a new request scope)
> once the current page has processed.  I can't seem to get this to work.
>
> Is there a session scope for the <h:messages>?
>
> Am I missing something basic?
>
> Thx.
>
> Mike
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: Tag Only Works Within a Request?

Posted by Mike Duffy <md...@yahoo.com>.
It seems like the best way to do this is to create a PhaseListener, "that moves messages from the
FacesContext to the user's session and back in the appropriate phases of the JSF lifecycle. "

Please see Variant 2:

http://jsffaq.com/Wiki.jsp?ptitle=How+to+show+Faces+Message+on+the+Next+Page%3F&page=HowToShowFacesMessageOnTheNextPage

I think this approach can be greatly simplified by not getting all the messages from the
FacesContext, then cycling through the messages and removing the client specific messages, then
putting the remaining messages into the session,  Rather, in most cases you are going to know the
message or messages you want to appear on the next page; it will be much simpler to place these
messages directly into a collection which is held in the session, and then all the PhaseListener
has to do is check the session object and get the messages at the beginning of the next cycle and
then put the messages into the FacesContext.

It seems like a cool approach.  I shall give it a try.

Thx to:  <a href="mailto:jesse@odel.on.ca">Jesse Wilson</a>

BTW:  Shouldn't this behavior be intrinsic to JSF?

Mike 


--- Mike Duffy <md...@yahoo.com> wrote:

> It seems that the <h:messages> tag only works within a request.  If something goes wrong on the
> current page, the messages display fine. 
> 
> What I would like to be able to do is display a message on the next page (in a new request
> scope)
> once the current page has processed.  I can't seem to get this to work.
> 
> Is there a session scope for the <h:messages>?
> 
> Am I missing something basic?
> 
> Thx.
> 
> Mike
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com