You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Victor Tatai <vt...@gmail.com> on 2005/05/23 20:09:15 UTC

Loosing global messages when using redirect

Hello,

We have a myfaces (1.0.9) application which uses global messages
extensively in order to notify the user about errors, successful
actions, etc. However when we add the <redirect/> tag to the
navigation cases the messages simply stop appearing. Is this a bug or
it is an expected behavior? Is there any way around this? We need the
redirect in order to enable proper activation of the servlet filters.

Thanks,

Victor

--
"Make things as simple as possible, but no simpler"
    -- Albert Einstein

Re: Loosing global messages when using redirect

Posted by Victor Tatai <vt...@gmail.com>.
I need a redirect for two things:

- Enable servlet filter security. This was solved by using the servlet
2.4 dispatcher config, but it is not really the best solution IMHO
because we have some apps which run on 2.3 containers (eg Tomcat 4.x).
Perhaps this could be done automatically by plugging the security
directly into JSF, but I am not sure how that would be done.

- Enable bookmarks. This is a nice to have feature, as some apps do
not require a login for some operations, and others have a "remember
me" feature which should work when bookmarking directly to a specific
functionality inside the app. This I really dont know how to
accomplish without a redirect :( .

Regards,

Victor

On 5/25/05, Sean Schofield <se...@gmail.com> wrote:
> You can't access the FacesContext in a servlet filter.  Its "released"
> once the service() method of the FacesServlet is completed.  (I ran
> into this problem just the other day.)
> 
> You could always create a listener for the various JSF lifecylce
> phases (Shale works off this principle.)  I still don't think this is
> what you really want to do.  What are you using redirect for?
> 
> If there is another way to solve that problem you will be better off.
> Messages in request scope is *not* the problem.  Its only causing you
> a problem because you are using redirect to do something you probably
> shouldn't be doing (or there is a better way to do it.)
> 
> HTH,
> 
> sean
> 
> On 5/25/05, Matt Blum <mb...@gmail.com> wrote:
> > Probably so.  I obviously didn't think that part through.  You'd have to
> > extract the values from the request object yourself (which is what the Faces
> > servlet does in order to put them in the FacesContext anyway), but that
> > seems a bit like reinventing the wheel.
> >
> >  I think you'd be better off redirecting to an intermediate step that would
> > extract the messages from the FacesContext and store them somewhere outside
> > the request scope, then redirect to the page you actually wanted to go to.
> > It's a bit of a hack, to be sure, but it's probably the only way to keep the
> > messages *and* allow your users to bookmark pages.
> >
> >
> >  -Matt
> >
> > On 5/25/05, Victor Tatai <vt...@gmail.com> wrote:
> > > Ok, I just tested it and FacesContext.getCurrentInstance() inside the
> > > filter returns null. Other people seem to have had the same problem
> > > also:
> > >
> > >
> > http://forum.java.sun.com/thread.jspa?forumID=427&threadID=598476
> > >
> > > I guess that perhaps the only approach possible is the #1 you
> > > described above, or a mix of both, what do you think?
> > >
> > > Regards,
> > >
> > > V.
> > >
> > > On 5/25/05, Matt Blum <mb...@gmail.com> wrote:
> > > > You should be able to call FacesContext.getCurrentInstance().
> > > >
> > > >  -Matt
> > > >
> > > >
> > > > On 5/25/05, Victor Tatai < vtatai@gmail.com> wrote:
> > > > > Implementing as a filter how would I be able to obtain the
> > > > > FacesContext in order to extract the messages?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Victor
> > > > >
> > > > > On 5/24/05, Matt Blum <mblum42@gmail.com > wrote:
> > > > > > I think that you might have to put the validation code in the
> > > > application
> > > > > > controller, so that, when the action is taken you can validate
> > whatever
> > > > you
> > > > > > need to validate, then put the messages in the FacesContext.  Either
> > > > that,
> > > > > > or include an extra step in the redirection that takes the messages
> > from
> > > > the
> > > > > > request and puts them in the FacesContext or the session, then
> > redirects
> > > > to
> > > > > > the page you were actually trying to go to.
> > > > > >
> > > > > >  Heck, you might even be able to get the second suggestion to work
> > using
> > > > a
> > > > > > filter.  Of course, if you do use the second method, you'll have to
> > be
> > > > sure
> > > > > > to *remove* the messages from the FacesContext or the session after
> > > > > > rendering the page, or they're just going to stay there.  The
> > advantage
> > > > of
> > > > > > them being stored in the request in the first place is that the
> > request
> > > > > > object is by nature transitory, so if you take away that advantage
> > > > you're
> > > > > > going to have to implement it yourself in whatever solution you
> > choose.
> > > > > >
> > > > > >  -Matt
> > > > > >
> > > > > >
> > > > > > On 5/24/05, Victor Tatai <vt...@gmail.com> wrote:
> > > > > > > Wouldn't you happen to know a way around this restriction? I would
> > > > > > > prefer to use redirect as it allows the use of bookmarks to pages.
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Victor
> > > > > > >
> > > > > > > On 5/23/05, Matt Blum < mblum42@gmail.com> wrote:
> > > > > > > > The messages are stored in the request object, and doing a
> > redirect
> > > > will
> > > > > > > > create a new request object, so yes, this is expected behavior.
> > > > There
> > > > > > is a
> > > > > > > > way to get the filters to fire even if you do a forward, as
> > detailed
> > > > in
> > > > > > this
> > > > > > > > message I wrote on a thread from a couple of weeks ago:
> > > > > > > >
> > > > > > > >   http://makeashorterlink.com/?Y5D61202B
> > > > > > > >
> > > > > > > >  HTH.
> > > > > > > >  -Matt
> > > > > > > >
> > > > > > > >
> > > > > > > > On 5/23/05, Victor Tatai < vtatai@gmail.com> wrote:
> > > > > > > > > Hello,
> > > > > > > > >
> > > > > > > > > We have a myfaces (1.0.9) application which uses global
> > messages
> > > > > > > > > extensively in order to notify the user about errors,
> > successful
> > > > > > > > > actions, etc. However when we add the <redirect/> tag to the
> > > > > > > > > navigation cases the messages simply stop appearing. Is this a
> > bug
> > > > or
> > > > > > > > > it is an expected behavior? Is there any way around this? We
> > need
> > > > the
> > > > > > > > > redirect in order to enable proper activation of the servlet
> > > > filters.
> > > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > >
> > > > > > > > > Victor
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > "Make things as simple as possible, but no simpler"
> > > > > > > > >     -- Albert Einstein
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > --
> > > > > > > "Make things as simple as possible, but no simpler"
> > > > > > >     -- Albert Einstein
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > --
> > > > > > > "Make things as simple as possible, but no simpler"
> > > > > > >     -- Albert Einstein
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > --
> > > > > "Make things as simple as possible, but no simpler"
> > > > >     -- Albert Einstein
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > --
> > > "Make things as simple as possible, but no simpler"
> > >     -- Albert Einstein
> > >
> >
> >
> 


-- 
--
"Make things as simple as possible, but no simpler"
    -- Albert Einstein

Re: Loosing global messages when using redirect

Posted by Sean Schofield <se...@gmail.com>.
You can't access the FacesContext in a servlet filter.  Its "released"
once the service() method of the FacesServlet is completed.  (I ran
into this problem just the other day.)

You could always create a listener for the various JSF lifecylce
phases (Shale works off this principle.)  I still don't think this is
what you really want to do.  What are you using redirect for?

If there is another way to solve that problem you will be better off. 
Messages in request scope is *not* the problem.  Its only causing you
a problem because you are using redirect to do something you probably
shouldn't be doing (or there is a better way to do it.)

HTH,

sean

On 5/25/05, Matt Blum <mb...@gmail.com> wrote:
> Probably so.  I obviously didn't think that part through.  You'd have to
> extract the values from the request object yourself (which is what the Faces
> servlet does in order to put them in the FacesContext anyway), but that
> seems a bit like reinventing the wheel.
>  
>  I think you'd be better off redirecting to an intermediate step that would
> extract the messages from the FacesContext and store them somewhere outside
> the request scope, then redirect to the page you actually wanted to go to. 
> It's a bit of a hack, to be sure, but it's probably the only way to keep the
> messages *and* allow your users to bookmark pages.
> 
>  
>  -Matt
> 
> On 5/25/05, Victor Tatai <vt...@gmail.com> wrote:
> > Ok, I just tested it and FacesContext.getCurrentInstance() inside the
> > filter returns null. Other people seem to have had the same problem
> > also:
> > 
> >
> http://forum.java.sun.com/thread.jspa?forumID=427&threadID=598476
> > 
> > I guess that perhaps the only approach possible is the #1 you
> > described above, or a mix of both, what do you think?
> > 
> > Regards,
> > 
> > V.
> > 
> > On 5/25/05, Matt Blum <mb...@gmail.com> wrote:
> > > You should be able to call FacesContext.getCurrentInstance().
> > >
> > >  -Matt
> > >
> > >
> > > On 5/25/05, Victor Tatai < vtatai@gmail.com> wrote:
> > > > Implementing as a filter how would I be able to obtain the
> > > > FacesContext in order to extract the messages?
> > > >
> > > > Thanks, 
> > > >
> > > > Victor
> > > >
> > > > On 5/24/05, Matt Blum <mblum42@gmail.com > wrote:
> > > > > I think that you might have to put the validation code in the 
> > > application
> > > > > controller, so that, when the action is taken you can validate
> whatever
> > > you
> > > > > need to validate, then put the messages in the FacesContext.  Either
> > > that, 
> > > > > or include an extra step in the redirection that takes the messages
> from
> > > the
> > > > > request and puts them in the FacesContext or the session, then
> redirects
> > > to
> > > > > the page you were actually trying to go to. 
> > > > >
> > > > >  Heck, you might even be able to get the second suggestion to work
> using
> > > a
> > > > > filter.  Of course, if you do use the second method, you'll have to
> be
> > > sure 
> > > > > to *remove* the messages from the FacesContext or the session after
> > > > > rendering the page, or they're just going to stay there.  The
> advantage
> > > of
> > > > > them being stored in the request in the first place is that the
> request 
> > > > > object is by nature transitory, so if you take away that advantage
> > > you're
> > > > > going to have to implement it yourself in whatever solution you
> choose.
> > > > >
> > > > >  -Matt 
> > > > >
> > > > >
> > > > > On 5/24/05, Victor Tatai <vt...@gmail.com> wrote:
> > > > > > Wouldn't you happen to know a way around this restriction? I would
> > > > > > prefer to use redirect as it allows the use of bookmarks to pages.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Victor
> > > > > >
> > > > > > On 5/23/05, Matt Blum < mblum42@gmail.com> wrote:
> > > > > > > The messages are stored in the request object, and doing a
> redirect
> > > will 
> > > > > > > create a new request object, so yes, this is expected behavior.
> > > There
> > > > > is a
> > > > > > > way to get the filters to fire even if you do a forward, as
> detailed 
> > > in
> > > > > this
> > > > > > > message I wrote on a thread from a couple of weeks ago:
> > > > > > >
> > > > > > >   http://makeashorterlink.com/?Y5D61202B
> > > > > > >
> > > > > > >  HTH.
> > > > > > >  -Matt
> > > > > > >
> > > > > > >
> > > > > > > On 5/23/05, Victor Tatai < vtatai@gmail.com> wrote:
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > We have a myfaces (1.0.9) application which uses global
> messages 
> > > > > > > > extensively in order to notify the user about errors,
> successful
> > > > > > > > actions, etc. However when we add the <redirect/> tag to the
> > > > > > > > navigation cases the messages simply stop appearing. Is this a
> bug 
> > > or
> > > > > > > > it is an expected behavior? Is there any way around this? We
> need
> > > the
> > > > > > > > redirect in order to enable proper activation of the servlet
> > > filters. 
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > >
> > > > > > > > Victor
> > > > > > > >
> > > > > > > > --
> > > > > > > > "Make things as simple as possible, but no simpler" 
> > > > > > > >     -- Albert Einstein
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > --
> > > > > > "Make things as simple as possible, but no simpler"
> > > > > >     -- Albert Einstein
> > > > > >
> > > > > >
> > > > > > -- 
> > > > > > --
> > > > > > "Make things as simple as possible, but no simpler"
> > > > > >     -- Albert Einstein
> > > > > >
> > > > >
> > > > >
> > > > 
> > > >
> > > > --
> > > > --
> > > > "Make things as simple as possible, but no simpler"
> > > >     -- Albert Einstein
> > > >
> > >
> > >
> > 
> > 
> > --
> > --
> > "Make things as simple as possible, but no simpler" 
> >     -- Albert Einstein
> > 
> 
>

Re: Loosing global messages when using redirect

Posted by Matt Blum <mb...@gmail.com>.
Probably so. I obviously didn't think that part through. You'd have to 
extract the values from the request object yourself (which is what the Faces 
servlet does in order to put them in the FacesContext anyway), but that 
seems a bit like reinventing the wheel.

I think you'd be better off redirecting to an intermediate step that would 
extract the messages from the FacesContext and store them somewhere outside 
the request scope, then redirect to the page you actually wanted to go to. 
It's a bit of a hack, to be sure, but it's probably the only way to keep the 
messages *and* allow your users to bookmark pages.

-Matt

On 5/25/05, Victor Tatai <vt...@gmail.com> wrote:
> 
> Ok, I just tested it and FacesContext.getCurrentInstance() inside the
> filter returns null. Other people seem to have had the same problem
> also:
> 
> http://forum.java.sun.com/thread.jspa?forumID=427&threadID=598476
> 
> I guess that perhaps the only approach possible is the #1 you
> described above, or a mix of both, what do you think?
> 
> Regards,
> 
> V.
> 
> On 5/25/05, Matt Blum <mb...@gmail.com> wrote:
> > You should be able to call FacesContext.getCurrentInstance().
> >
> > -Matt
> >
> >
> > On 5/25/05, Victor Tatai <vt...@gmail.com> wrote:
> > > Implementing as a filter how would I be able to obtain the
> > > FacesContext in order to extract the messages?
> > >
> > > Thanks,
> > >
> > > Victor
> > >
> > > On 5/24/05, Matt Blum <mblum42@gmail.com > wrote:
> > > > I think that you might have to put the validation code in the
> > application
> > > > controller, so that, when the action is taken you can validate 
> whatever
> > you
> > > > need to validate, then put the messages in the FacesContext. Either
> > that,
> > > > or include an extra step in the redirection that takes the messages 
> from
> > the
> > > > request and puts them in the FacesContext or the session, then 
> redirects
> > to
> > > > the page you were actually trying to go to.
> > > >
> > > > Heck, you might even be able to get the second suggestion to work 
> using
> > a
> > > > filter. Of course, if you do use the second method, you'll have to 
> be
> > sure
> > > > to *remove* the messages from the FacesContext or the session after
> > > > rendering the page, or they're just going to stay there. The 
> advantage
> > of
> > > > them being stored in the request in the first place is that the 
> request
> > > > object is by nature transitory, so if you take away that advantage
> > you're
> > > > going to have to implement it yourself in whatever solution you 
> choose.
> > > >
> > > > -Matt
> > > >
> > > >
> > > > On 5/24/05, Victor Tatai <vt...@gmail.com> wrote:
> > > > > Wouldn't you happen to know a way around this restriction? I would
> > > > > prefer to use redirect as it allows the use of bookmarks to pages.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Victor
> > > > >
> > > > > On 5/23/05, Matt Blum < mblum42@gmail.com> wrote:
> > > > > > The messages are stored in the request object, and doing a 
> redirect
> > will
> > > > > > create a new request object, so yes, this is expected behavior.
> > There
> > > > is a
> > > > > > way to get the filters to fire even if you do a forward, as 
> detailed
> > in
> > > > this
> > > > > > message I wrote on a thread from a couple of weeks ago:
> > > > > >
> > > > > > http://makeashorterlink.com/?Y5D61202B
> > > > > >
> > > > > > HTH.
> > > > > > -Matt
> > > > > >
> > > > > >
> > > > > > On 5/23/05, Victor Tatai < vtatai@gmail.com> wrote:
> > > > > > > Hello,
> > > > > > >
> > > > > > > We have a myfaces (1.0.9) application which uses global 
> messages
> > > > > > > extensively in order to notify the user about errors, 
> successful
> > > > > > > actions, etc. However when we add the <redirect/> tag to the
> > > > > > > navigation cases the messages simply stop appearing. Is this a 
> bug
> > or
> > > > > > > it is an expected behavior? Is there any way around this? We 
> need
> > the
> > > > > > > redirect in order to enable proper activation of the servlet
> > filters.
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Victor
> > > > > > >
> > > > > > > --
> > > > > > > "Make things as simple as possible, but no simpler"
> > > > > > > -- Albert Einstein
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > --
> > > > > "Make things as simple as possible, but no simpler"
> > > > > -- Albert Einstein
> > > > >
> > > > >
> > > > > --
> > > > > --
> > > > > "Make things as simple as possible, but no simpler"
> > > > > -- Albert Einstein
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > --
> > > "Make things as simple as possible, but no simpler"
> > > -- Albert Einstein
> > >
> >
> >
> 
> 
> --
> --
> "Make things as simple as possible, but no simpler"
> -- Albert Einstein
>

Re: Loosing global messages when using redirect

Posted by Victor Tatai <vt...@gmail.com>.
Ok, I just tested it and FacesContext.getCurrentInstance() inside the
filter returns null. Other people seem to have had the same problem
also:

http://forum.java.sun.com/thread.jspa?forumID=427&threadID=598476

I guess that perhaps the only approach possible is the #1 you
described above, or a mix of both, what do you think?

Regards,

V.

On 5/25/05, Matt Blum <mb...@gmail.com> wrote:
> You should be able to call FacesContext.getCurrentInstance().
>  
>  -Matt
> 
> 
> On 5/25/05, Victor Tatai <vt...@gmail.com> wrote:
> > Implementing as a filter how would I be able to obtain the
> > FacesContext in order to extract the messages?
> > 
> > Thanks,
> > 
> > Victor
> > 
> > On 5/24/05, Matt Blum <mblum42@gmail.com > wrote:
> > > I think that you might have to put the validation code in the
> application
> > > controller, so that, when the action is taken you can validate whatever
> you
> > > need to validate, then put the messages in the FacesContext.  Either
> that, 
> > > or include an extra step in the redirection that takes the messages from
> the
> > > request and puts them in the FacesContext or the session, then redirects
> to
> > > the page you were actually trying to go to. 
> > >
> > >  Heck, you might even be able to get the second suggestion to work using
> a
> > > filter.  Of course, if you do use the second method, you'll have to be
> sure
> > > to *remove* the messages from the FacesContext or the session after 
> > > rendering the page, or they're just going to stay there.  The advantage
> of
> > > them being stored in the request in the first place is that the request
> > > object is by nature transitory, so if you take away that advantage
> you're 
> > > going to have to implement it yourself in whatever solution you choose.
> > >
> > >  -Matt
> > >
> > >
> > > On 5/24/05, Victor Tatai <vt...@gmail.com> wrote: 
> > > > Wouldn't you happen to know a way around this restriction? I would
> > > > prefer to use redirect as it allows the use of bookmarks to pages.
> > > >
> > > > Thanks,
> > > >
> > > > Victor 
> > > >
> > > > On 5/23/05, Matt Blum < mblum42@gmail.com> wrote:
> > > > > The messages are stored in the request object, and doing a redirect
> will
> > > > > create a new request object, so yes, this is expected behavior. 
> There 
> > > is a
> > > > > way to get the filters to fire even if you do a forward, as detailed
> in
> > > this
> > > > > message I wrote on a thread from a couple of weeks ago:
> > > > >
> > > > >   http://makeashorterlink.com/?Y5D61202B
> > > > >
> > > > >  HTH.
> > > > >  -Matt
> > > > >
> > > > >
> > > > > On 5/23/05, Victor Tatai < vtatai@gmail.com> wrote:
> > > > > > Hello,
> > > > > >
> > > > > > We have a myfaces (1.0.9) application which uses global messages
> > > > > > extensively in order to notify the user about errors, successful 
> > > > > > actions, etc. However when we add the <redirect/> tag to the
> > > > > > navigation cases the messages simply stop appearing. Is this a bug
> or
> > > > > > it is an expected behavior? Is there any way around this? We need
> the 
> > > > > > redirect in order to enable proper activation of the servlet
> filters.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Victor
> > > > > > 
> > > > > > --
> > > > > > "Make things as simple as possible, but no simpler"
> > > > > >     -- Albert Einstein
> > > > > >
> > > > >
> > > > >
> > > > 
> > > >
> > > > --
> > > > --
> > > > "Make things as simple as possible, but no simpler"
> > > >     -- Albert Einstein
> > > >
> > > >
> > > > --
> > > > --
> > > > "Make things as simple as possible, but no simpler" 
> > > >     -- Albert Einstein
> > > >
> > >
> > >
> > 
> > 
> > --
> > --
> > "Make things as simple as possible, but no simpler"
> >     -- Albert Einstein
> > 
> 
>  


-- 
--
"Make things as simple as possible, but no simpler"
    -- Albert Einstein

Re: Loosing global messages when using redirect

Posted by Matt Blum <mb...@gmail.com>.
You should be able to call FacesContext.getCurrentInstance().

-Matt

On 5/25/05, Victor Tatai <vt...@gmail.com> wrote:
> 
> Implementing as a filter how would I be able to obtain the
> FacesContext in order to extract the messages?
> 
> Thanks,
> 
> Victor
> 
> On 5/24/05, Matt Blum <mb...@gmail.com> wrote:
> > I think that you might have to put the validation code in the 
> application
> > controller, so that, when the action is taken you can validate whatever 
> you
> > need to validate, then put the messages in the FacesContext. Either 
> that,
> > or include an extra step in the redirection that takes the messages from 
> the
> > request and puts them in the FacesContext or the session, then redirects 
> to
> > the page you were actually trying to go to.
> >
> > Heck, you might even be able to get the second suggestion to work using 
> a
> > filter. Of course, if you do use the second method, you'll have to be 
> sure
> > to *remove* the messages from the FacesContext or the session after
> > rendering the page, or they're just going to stay there. The advantage 
> of
> > them being stored in the request in the first place is that the request
> > object is by nature transitory, so if you take away that advantage 
> you're
> > going to have to implement it yourself in whatever solution you choose.
> >
> > -Matt
> >
> >
> > On 5/24/05, Victor Tatai <vt...@gmail.com> wrote:
> > > Wouldn't you happen to know a way around this restriction? I would
> > > prefer to use redirect as it allows the use of bookmarks to pages.
> > >
> > > Thanks,
> > >
> > > Victor
> > >
> > > On 5/23/05, Matt Blum < mblum42@gmail.com> wrote:
> > > > The messages are stored in the request object, and doing a redirect 
> will
> > > > create a new request object, so yes, this is expected behavior. 
> There
> > is a
> > > > way to get the filters to fire even if you do a forward, as detailed 
> in
> > this
> > > > message I wrote on a thread from a couple of weeks ago:
> > > >
> > > > http://makeashorterlink.com/?Y5D61202B
> > > >
> > > > HTH.
> > > > -Matt
> > > >
> > > >
> > > > On 5/23/05, Victor Tatai <vt...@gmail.com> wrote:
> > > > > Hello,
> > > > >
> > > > > We have a myfaces (1.0.9) application which uses global messages
> > > > > extensively in order to notify the user about errors, successful
> > > > > actions, etc. However when we add the <redirect/> tag to the
> > > > > navigation cases the messages simply stop appearing. Is this a bug 
> or
> > > > > it is an expected behavior? Is there any way around this? We need 
> the
> > > > > redirect in order to enable proper activation of the servlet 
> filters.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Victor
> > > > >
> > > > > --
> > > > > "Make things as simple as possible, but no simpler"
> > > > > -- Albert Einstein
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > --
> > > "Make things as simple as possible, but no simpler"
> > > -- Albert Einstein
> > >
> > >
> > > --
> > > --
> > > "Make things as simple as possible, but no simpler"
> > > -- Albert Einstein
> > >
> >
> >
> 
> 
> --
> --
> "Make things as simple as possible, but no simpler"
> -- Albert Einstein
>

Re: Loosing global messages when using redirect

Posted by Victor Tatai <vt...@gmail.com>.
Implementing as a filter how would I be able to obtain the
FacesContext in order to extract the messages?

Thanks,

Victor

On 5/24/05, Matt Blum <mb...@gmail.com> wrote:
> I think that you might have to put the validation code in the application
> controller, so that, when the action is taken you can validate whatever you
> need to validate, then put the messages in the FacesContext.  Either that,
> or include an extra step in the redirection that takes the messages from the
> request and puts them in the FacesContext or the session, then redirects to
> the page you were actually trying to go to.
>  
>  Heck, you might even be able to get the second suggestion to work using a
> filter.  Of course, if you do use the second method, you'll have to be sure
> to *remove* the messages from the FacesContext or the session after
> rendering the page, or they're just going to stay there.  The advantage of
> them being stored in the request in the first place is that the request
> object is by nature transitory, so if you take away that advantage you're
> going to have to implement it yourself in whatever solution you choose.
>  
>  -Matt
> 
> 
> On 5/24/05, Victor Tatai <vt...@gmail.com> wrote:
> > Wouldn't you happen to know a way around this restriction? I would
> > prefer to use redirect as it allows the use of bookmarks to pages.
> > 
> > Thanks,
> > 
> > Victor
> > 
> > On 5/23/05, Matt Blum < mblum42@gmail.com> wrote:
> > > The messages are stored in the request object, and doing a redirect will
> > > create a new request object, so yes, this is expected behavior.  There
> is a
> > > way to get the filters to fire even if you do a forward, as detailed in
> this 
> > > message I wrote on a thread from a couple of weeks ago:
> > >
> > >  http://makeashorterlink.com/?Y5D61202B
> > >
> > >  HTH.
> > >  -Matt
> > >
> > >
> > > On 5/23/05, Victor Tatai <vt...@gmail.com> wrote:
> > > > Hello,
> > > >
> > > > We have a myfaces (1.0.9) application which uses global messages
> > > > extensively in order to notify the user about errors, successful
> > > > actions, etc. However when we add the <redirect/> tag to the
> > > > navigation cases the messages simply stop appearing. Is this a bug or 
> > > > it is an expected behavior? Is there any way around this? We need the
> > > > redirect in order to enable proper activation of the servlet filters.
> > > >
> > > > Thanks,
> > > >
> > > > Victor 
> > > >
> > > > --
> > > > "Make things as simple as possible, but no simpler"
> > > >     -- Albert Einstein
> > > >
> > >
> > >
> > 
> > 
> > --
> > --
> > "Make things as simple as possible, but no simpler" 
> >     -- Albert Einstein
> > 
> > 
> > --
> > --
> > "Make things as simple as possible, but no simpler"
> >     -- Albert Einstein
> > 
> 
>  


-- 
--
"Make things as simple as possible, but no simpler"
    -- Albert Einstein

Re: Loosing global messages when using redirect

Posted by Matt Blum <mb...@gmail.com>.
I think that you might have to put the validation code in the application 
controller, so that, when the action is taken you can validate whatever you 
need to validate, then put the messages in the FacesContext. Either that, or 
include an extra step in the redirection that takes the messages from the 
request and puts them in the FacesContext or the session, then redirects to 
the page you were actually trying to go to.

Heck, you might even be able to get the second suggestion to work using a 
filter. Of course, if you do use the second method, you'll have to be sure 
to *remove* the messages from the FacesContext or the session after 
rendering the page, or they're just going to stay there. The advantage of 
them being stored in the request in the first place is that the request 
object is by nature transitory, so if you take away that advantage you're 
going to have to implement it yourself in whatever solution you choose.

-Matt

On 5/24/05, Victor Tatai <vt...@gmail.com> wrote:
> 
> Wouldn't you happen to know a way around this restriction? I would
> prefer to use redirect as it allows the use of bookmarks to pages.
> 
> Thanks,
> 
> Victor
> 
> On 5/23/05, Matt Blum <mb...@gmail.com> wrote:
> > The messages are stored in the request object, and doing a redirect will
> > create a new request object, so yes, this is expected behavior. There is 
> a
> > way to get the filters to fire even if you do a forward, as detailed in 
> this
> > message I wrote on a thread from a couple of weeks ago:
> >
> > http://makeashorterlink.com/?Y5D61202B
> >
> > HTH.
> > -Matt
> >
> >
> > On 5/23/05, Victor Tatai <vt...@gmail.com> wrote:
> > > Hello,
> > >
> > > We have a myfaces (1.0.9) application which uses global messages
> > > extensively in order to notify the user about errors, successful
> > > actions, etc. However when we add the <redirect/> tag to the
> > > navigation cases the messages simply stop appearing. Is this a bug or
> > > it is an expected behavior? Is there any way around this? We need the
> > > redirect in order to enable proper activation of the servlet filters.
> > >
> > > Thanks,
> > >
> > > Victor
> > >
> > > --
> > > "Make things as simple as possible, but no simpler"
> > > -- Albert Einstein
> > >
> >
> >
> 
> 
> --
> --
> "Make things as simple as possible, but no simpler"
> -- Albert Einstein
> 
> 
> --
> --
> "Make things as simple as possible, but no simpler"
> -- Albert Einstein
>

Re: Loosing global messages when using redirect

Posted by Victor Tatai <vt...@gmail.com>.
Wouldn't you happen to know a way around this restriction? I would
prefer to use redirect as it allows the use of bookmarks to pages.

Thanks,

Victor

On 5/23/05, Matt Blum <mb...@gmail.com> wrote:
> The messages are stored in the request object, and doing a redirect will
> create a new request object, so yes, this is expected behavior.  There is a
> way to get the filters to fire even if you do a forward, as detailed in this
> message I wrote on a thread from a couple of weeks ago:
>
>  http://makeashorterlink.com/?Y5D61202B
>
>  HTH.
>  -Matt
>
>
> On 5/23/05, Victor Tatai <vt...@gmail.com> wrote:
> > Hello,
> >
> > We have a myfaces (1.0.9) application which uses global messages
> > extensively in order to notify the user about errors, successful
> > actions, etc. However when we add the <redirect/> tag to the
> > navigation cases the messages simply stop appearing. Is this a bug or
> > it is an expected behavior? Is there any way around this? We need the
> > redirect in order to enable proper activation of the servlet filters.
> >
> > Thanks,
> >
> > Victor
> >
> > --
> > "Make things as simple as possible, but no simpler"
> >     -- Albert Einstein
> >
>
>


--
--
"Make things as simple as possible, but no simpler"
    -- Albert Einstein


-- 
--
"Make things as simple as possible, but no simpler"
    -- Albert Einstein

Re: Loosing global messages when using redirect

Posted by Matt Blum <mb...@gmail.com>.
The messages are stored in the request object, and doing a redirect will 
create a new request object, so yes, this is expected behavior. There is a 
way to get the filters to fire even if you do a forward, as detailed in this 
message I wrote on a thread from a couple of weeks ago:

http://makeashorterlink.com/?Y5D61202B

HTH.
-Matt

On 5/23/05, Victor Tatai <vt...@gmail.com> wrote:
> 
> Hello,
> 
> We have a myfaces (1.0.9) application which uses global messages
> extensively in order to notify the user about errors, successful
> actions, etc. However when we add the <redirect/> tag to the
> navigation cases the messages simply stop appearing. Is this a bug or 
> it is an expected behavior? Is there any way around this? We need the
> redirect in order to enable proper activation of the servlet filters.
> 
> Thanks,
> 
> Victor
> 
> --
> "Make things as simple as possible, but no simpler" 
> -- Albert Einstein
>