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 <[EMAIL PROTECTED]> wrote:
> You should be able to call FacesContext.getCurrentInstance().
>  
>  -Matt
> 
> 
> On 5/25/05, Victor Tatai <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED] > 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 <[EMAIL PROTECTED]> 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 < [EMAIL PROTECTED]> 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 < [EMAIL PROTECTED]> 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

Reply via email to