You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Steve Torrefranca <st...@branders.com> on 2007/04/23 20:57:59 UTC

and FacesMessage problem

<t:messages /> suddenly stopped working after I used <redirect/>.  How 
do I keep FacesMessage's state if I use redirect?

Thank you.

-Steve

Re: and FacesMessage problem

Posted by Mike Kienenberger <mk...@gmail.com>.
There's also the Tomahawk sandbox RedirectTracker if you don't want a
Seam dependency.

Unfortunately, it's pretty light on documention right now.

Try here:

http://issues.apache.org/jira/browse/TOMAHAWK-503

http://mail-archives.apache.org/mod_mbox/myfaces-dev/200606.mbox/%3C449A98FF.6060604@ops.co.at%3E

On 4/23/07, Andrew Robinson <an...@gmail.com> wrote:
> That is expected. Best way I know to keep them around is to use Seam
> and follow the instructions on using the seam redirect filter.
>
> On 4/23/07, Steve Torrefranca <st...@branders.com> wrote:
> > <t:messages /> suddenly stopped working after I used <redirect/>.  How
> > do I keep FacesMessage's state if I use redirect?
> >
> > Thank you.
> >
> > -Steve
> >
>

Re: and FacesMessage problem

Posted by Andrew Robinson <an...@gmail.com>.
That is expected. Best way I know to keep them around is to use Seam
and follow the instructions on using the seam redirect filter.

On 4/23/07, Steve Torrefranca <st...@branders.com> wrote:
> <t:messages /> suddenly stopped working after I used <redirect/>.  How
> do I keep FacesMessage's state if I use redirect?
>
> Thank you.
>
> -Steve
>

RE: and FacesMessage problem

Posted by "Garner, Shawn" <sh...@vangent.com>.
Probably not the best case scenario but it sounds like you could use a
custom converter.

I assume that will get called every time.

 

Shawn 

________________________________

From: Steve Torrefranca [mailto:storrefranca@branders.com] 
Sent: Monday, April 23, 2007 3:19 PM
To: MyFaces Discussion
Subject: Re: <redirect /> and FacesMessage problem

 

i have thought of using a validator.  the only problem is that if the
value is null, the validator isn't called.

the message needs to warn/remind user (does not give an error and let
the user continue) that he/she has left these fields blank.  i cn't use
required="true" either since we allow fields to be null and all we do is
display the null values of the previous page.  It's weird I know but
well.... <sigh>

therefore we do the validation on the event method and build the
Messages there as we redirect the user to the next page.

-Steve


Garner, Shawn wrote: 

You can have application level messages and validation level messages.
 
If you create a message in your application method you would expect it
to display on the next page regardless of which page you navigate to.
 
This is in contrast to a validation message which it must pass the
validation phase.
 
Shawn
 
-----Original Message-----
From: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
Sent: Monday, April 23, 2007 3:04 PM
To: MyFaces Discussion
Subject: Re: <redirect /> and FacesMessage problem
 
Steve Torrefranca wrote:
  

	<t:messages /> suddenly stopped working after I used
<redirect/>.  How
	    

 
  

	do I keep FacesMessage's state if I use redirect?
	    

 
Why would you want to?
 
If a page has error messages then navigation will not occur. If a page 
does not have error messages, then "losing them" on navigation is not a 
problem as there are none to lose.
 
What scenario do you have that needs to preserve messages on navigation 
via redirect?
 
  

 


Re: and FacesMessage problem

Posted by Steve Torrefranca <st...@branders.com>.
i have thought of using a validator.  the only problem is that if the 
value is null, the validator isn't called.

the message needs to warn/remind user (does not give an error and let 
the user continue) that he/she has left these fields blank.  i cn't use 
required="true" either since we allow fields to be null and all we do is 
display the null values of the previous page.  It's weird I know but 
well.... <sigh>

therefore we do the validation on the event method and build the 
Messages there as we redirect the user to the next page.

-Steve


Garner, Shawn wrote:
> You can have application level messages and validation level messages.
>
> If you create a message in your application method you would expect it
> to display on the next page regardless of which page you navigate to.
>
> This is in contrast to a validation message which it must pass the
> validation phase.
>
> Shawn
>  
> -----Original Message-----
> From: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
> Sent: Monday, April 23, 2007 3:04 PM
> To: MyFaces Discussion
> Subject: Re: <redirect /> and FacesMessage problem
>
> Steve Torrefranca wrote:
>   
>> <t:messages /> suddenly stopped working after I used <redirect/>.  How
>>     
>
>   
>> do I keep FacesMessage's state if I use redirect?
>>     
>
> Why would you want to?
>
> If a page has error messages then navigation will not occur. If a page 
> does not have error messages, then "losing them" on navigation is not a 
> problem as there are none to lose.
>
> What scenario do you have that needs to preserve messages on navigation 
> via redirect?
>
>   


RE: and FacesMessage problem

Posted by "Garner, Shawn" <sh...@vangent.com>.
You can have application level messages and validation level messages.

If you create a message in your application method you would expect it
to display on the next page regardless of which page you navigate to.

This is in contrast to a validation message which it must pass the
validation phase.

Shawn
 
-----Original Message-----
From: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
Sent: Monday, April 23, 2007 3:04 PM
To: MyFaces Discussion
Subject: Re: <redirect /> and FacesMessage problem

Steve Torrefranca wrote:
> <t:messages /> suddenly stopped working after I used <redirect/>.  How

> do I keep FacesMessage's state if I use redirect?

Why would you want to?

If a page has error messages then navigation will not occur. If a page 
does not have error messages, then "losing them" on navigation is not a 
problem as there are none to lose.

What scenario do you have that needs to preserve messages on navigation 
via redirect?

Re: and FacesMessage problem

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> So I don't need to register a PhaseListener or anything?
>   
Yep, no additional registration required. You'll get it automatically
through the tomahawk sandbox jar.

---
Mario
> Shawn
>
> -----Original Message-----
> From: Mario Ivankovits [mailto:mario@ops.co.at] 
> Sent: Tuesday, April 24, 2007 2:40 AM
> To: MyFaces Discussion
> Subject: Re: <redirect /> and FacesMessage problem
>
> Hi!
>   
>> I was checking out the RedirectTracker documentation.  Is there any
>> installation/usage documents other than the javadoc?
>>   
>>     
> To make use of the RedirectTracker you have to:
>
> * add the myfaces sandbox to your project
> * configure the init paramter
> "org.apache.myfaces.redirectTracker.POLICY" in your web.xml, set it to
> one of the following values:
>
> **
> org.apache.myfaces.custom.redirectTracker.policy.FullRedirectTrackPolicy
> captures the locale, request scoped beans, messages
>
> **
> org.apache.myfaces.custom.redirectTracker.policy.MessagesRedirectTrackPo
> licy
> captures messages only
>
> **
> org.apache.myfaces.custom.redirectTracker.policy.NoopRedirectTrackPolicy
> captures nothing - the default
>
> * configure org.apache.myfaces.redirectTracker.MAX_REDIRECTS if required
> (default is 20)
>
>
> If everything went fine you should see an additional parameter "_rtid="
> added to the url (after the redirect). This will be used to find the
> captured data within the session. Simply adding the data to the session
> will not work with browser back, reload, multiple windows etc.
>
>
> Hope this helps for a start.
>
> Ciao,
> Mario
>
>   


-- 
mit freundlichen Grüßen

Mario Ivankovits
Software Engineering

OPS EDV VertriebsgesmbH
A-1120 Wien, Michael-Bernhard-Gasse 10

Firmenbuch Nr.: FN51233v, Handelsgericht Wien
Tel.: +43-1-8938810; Fax: +43-1-8938810/3700
http://www.ops.co.at

E-Mail: mario@ops.co.at
Skype: mario_ivankovits


RE: and FacesMessage problem

Posted by "Garner, Shawn" <sh...@vangent.com>.
So I don't need to register a PhaseListener or anything?

Shawn

-----Original Message-----
From: Mario Ivankovits [mailto:mario@ops.co.at] 
Sent: Tuesday, April 24, 2007 2:40 AM
To: MyFaces Discussion
Subject: Re: <redirect /> and FacesMessage problem

Hi!
> I was checking out the RedirectTracker documentation.  Is there any
> installation/usage documents other than the javadoc?
>   
To make use of the RedirectTracker you have to:

* add the myfaces sandbox to your project
* configure the init paramter
"org.apache.myfaces.redirectTracker.POLICY" in your web.xml, set it to
one of the following values:

**
org.apache.myfaces.custom.redirectTracker.policy.FullRedirectTrackPolicy
captures the locale, request scoped beans, messages

**
org.apache.myfaces.custom.redirectTracker.policy.MessagesRedirectTrackPo
licy
captures messages only

**
org.apache.myfaces.custom.redirectTracker.policy.NoopRedirectTrackPolicy
captures nothing - the default

* configure org.apache.myfaces.redirectTracker.MAX_REDIRECTS if required
(default is 20)


If everything went fine you should see an additional parameter "_rtid="
added to the url (after the redirect). This will be used to find the
captured data within the session. Simply adding the data to the session
will not work with browser back, reload, multiple windows etc.


Hope this helps for a start.

Ciao,
Mario


Re: and FacesMessage problem

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> I was checking out the RedirectTracker documentation.  Is there any
> installation/usage documents other than the javadoc?
>   
To make use of the RedirectTracker you have to:

* add the myfaces sandbox to your project
* configure the init paramter
"org.apache.myfaces.redirectTracker.POLICY" in your web.xml, set it to
one of the following values:

** org.apache.myfaces.custom.redirectTracker.policy.FullRedirectTrackPolicy
captures the locale, request scoped beans, messages

**
org.apache.myfaces.custom.redirectTracker.policy.MessagesRedirectTrackPolicy
captures messages only

** org.apache.myfaces.custom.redirectTracker.policy.NoopRedirectTrackPolicy
captures nothing - the default

* configure org.apache.myfaces.redirectTracker.MAX_REDIRECTS if required
(default is 20)


If everything went fine you should see an additional parameter "_rtid="
added to the url (after the redirect). This will be used to find the
captured data within the session. Simply adding the data to the session
will not work with browser back, reload, multiple windows etc.


Hope this helps for a start.

Ciao,
Mario


RE: and FacesMessage problem

Posted by "Garner, Shawn" <sh...@vangent.com>.
I was checking out the RedirectTracker documentation.  Is there any
installation/usage documents other than the javadoc?

Shawn

-----Original Message-----
From: Steve Torrefranca [mailto:storrefranca@branders.com] 
Sent: Monday, April 23, 2007 3:40 PM
To: MyFaces Discussion
Subject: Re: <redirect /> and FacesMessage problem

Thanks guys!  I guess it's high time for me to put sandbox in our
project

-Steve

Re: and FacesMessage problem

Posted by Steve Torrefranca <st...@branders.com>.
Thanks guys!  I guess it's high time for me to put sandbox in our project

-Steve

Re: and FacesMessage problem

Posted by Mike Kienenberger <mk...@gmail.com>.
Simon, I think that's what the redirect tracker in the sandbox does/is
(phase listener).  It also handles t:saveState if I recall.



On 4/23/07, Simon Kitching <si...@rhe.co.nz> wrote:
> Steve Torrefranca wrote:
> > Simon Kitching wrote:
> >>
> >> What scenario do you have that needs to preserve messages on
> >> navigation via redirect?
> >>
> > we are rewriting an old app.  the problem with forward, users complain,
> > is that the name of the page (url) does not change and is misleading.
> >
> > the user has to go through a series of page where messages (if it is
> > just info/warning) will be displayed on the next page.  i know its weird
> > but that is how the old app is doing it and users demand we follow that
> > flow.
>
> Ah users, the source of all our problems :-)
>
> Well, the issue is that a FacesContext is only request-scoped. Calling
> FacesContext.addMessage stores the message on the FacesContext instance.
> On a later http request messages are therefore not present.
>
> One solution would be to have a custom tag that you place at the bottom
> of a page which calls FacesContext.getMessages() and stores them into
> the user's http session. Or you could just register your custom messages
> that are expected to carry across pages directly into the session. Or
> maybe a PhaseListener could do this (though you'd need to figure out
> which messages are to be stored and which are not). A PhaseListener
> could then be written that runs on pre-render and moves all messages in
> the session onto the current FacesContext. Maybe the sandbox
> RedirectTracker already does that...
>
> Regards,
>
> Simon
>

Re: and FacesMessage problem

Posted by Simon Kitching <si...@rhe.co.nz>.
Steve Torrefranca wrote:
> Simon Kitching wrote:
>>
>> What scenario do you have that needs to preserve messages on 
>> navigation via redirect?
>>
> we are rewriting an old app.  the problem with forward, users complain, 
> is that the name of the page (url) does not change and is misleading.
> 
> the user has to go through a series of page where messages (if it is 
> just info/warning) will be displayed on the next page.  i know its weird 
> but that is how the old app is doing it and users demand we follow that 
> flow.

Ah users, the source of all our problems :-)

Well, the issue is that a FacesContext is only request-scoped. Calling 
FacesContext.addMessage stores the message on the FacesContext instance. 
On a later http request messages are therefore not present.

One solution would be to have a custom tag that you place at the bottom 
of a page which calls FacesContext.getMessages() and stores them into 
the user's http session. Or you could just register your custom messages 
that are expected to carry across pages directly into the session. Or 
maybe a PhaseListener could do this (though you'd need to figure out 
which messages are to be stored and which are not). A PhaseListener 
could then be written that runs on pre-render and moves all messages in 
the session onto the current FacesContext. Maybe the sandbox 
RedirectTracker already does that...

Regards,

Simon

Re: and FacesMessage problem

Posted by Mike Kienenberger <mk...@gmail.com>.
It's not necessarily all that wierd.   You might process a credit card
on one page and display messages on the following "transaction
completed" page if there were any informational or warning-level
errors.

On 4/23/07, Steve Torrefranca <st...@branders.com> wrote:
> Simon Kitching wrote:
> >
> > What scenario do you have that needs to preserve messages on
> > navigation via redirect?
> >
> we are rewriting an old app.  the problem with forward, users complain,
> is that the name of the page (url) does not change and is misleading.
>
> the user has to go through a series of page where messages (if it is
> just info/warning) will be displayed on the next page.  i know its weird
> but that is how the old app is doing it and users demand we follow that
> flow.
>

Re: and FacesMessage problem

Posted by Steve Torrefranca <st...@branders.com>.
Simon Kitching wrote:
>
> What scenario do you have that needs to preserve messages on 
> navigation via redirect?
>
we are rewriting an old app.  the problem with forward, users complain, 
is that the name of the page (url) does not change and is misleading.

the user has to go through a series of page where messages (if it is 
just info/warning) will be displayed on the next page.  i know its weird 
but that is how the old app is doing it and users demand we follow that 
flow.

Re: and FacesMessage problem

Posted by Simon Kitching <si...@rhe.co.nz>.
Steve Torrefranca wrote:
> <t:messages /> suddenly stopped working after I used <redirect/>.  How 
> do I keep FacesMessage's state if I use redirect?

Why would you want to?

If a page has error messages then navigation will not occur. If a page 
does not have error messages, then "losing them" on navigation is not a 
problem as there are none to lose.

What scenario do you have that needs to preserve messages on navigation 
via redirect?

Re: and FacesMessage problem

Posted by Josué Alcalde González <jo...@gmail.com>.
El lun, 23-04-2007 a las 11:57 -0700, Steve Torrefranca escribió:

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

> <t:messages /> suddenly stopped working after I used <redirect/>.  How 
> do I keep FacesMessage's state if I use redirect?
> 
> Thank you.
> 
> -Steve