You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Mario Ivankovits <ma...@ops.co.at> on 2007/03/28 10:30:40 UTC

FacesServlet and preconfigured FacesContext

Hi!

I create my own FacesContext in an ServletFilter (in the end around the
FacesServlet).

The FacesServlet itself too creates a FacesContext.

In the end I have some problems with this setup as the Faces Messages
added to my FacesContext are never shown as the JSF system will use the
FacesContext created by the FacesServlet.

The question is:
Shouldn't the FacesServlet check if there is a FacesContext and use this
one instead of creating a new one?
What do the RI do?

Ciao,
Mario


Re: FacesServlet and preconfigured FacesContext

Posted by Mario Ivankovits <ma...@ops.co.at>.
Just for the records: http://wiki.apache.org/myfaces/NestedFacesContext
> wiki sounds fine!


Re: FacesServlet and preconfigured FacesContext

Posted by Matthias Wessendorf <ma...@apache.org>.
wiki sounds fine!

On 3/28/07, Mario Ivankovits <ma...@ops.co.at> wrote:
> Hi!
> > perhaps the FacesCtxFactory should check that ?
> Ok, It turned out to be a little bit a complicated problem.
>
> First my use case:
>
> * A custom filter which creates a custom facesContext
> * A custom servlet which forwards to the FacesServlet
> (getServletContext().getRequestDispatcher(jsfPath).forward(req, res);)
> * The FacesServlet which creates a facesContext too
>
> I tried a custom FacesContextFactory which checks if there is already a
> facesContext and returns it if this is the case.
> It turned out that this can not work as the
> servletRequest/servletResponse objects from the filter are not the same
> as the one the FacesServlet sees.
> In the end the forward did not work due to the fact that the JSF system
> still sees the values from the Req/Rep objects hold by the custom
> FacesContext from the filter.
>
> I solved it with a custom FacesContext factory by checking to see if
> there is a previous context .... and if so ... get some of its values
> (locale/messages) and put them to the new facesContext.
>
> If we think this is of any use for someone else with such an "exotic"
> setup I can add the code to the sandbox or a wiki page.
>
> Ciao,
> Mario
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: FacesServlet and preconfigured FacesContext

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> perhaps the FacesCtxFactory should check that ?
Ok, It turned out to be a little bit a complicated problem.

First my use case:

* A custom filter which creates a custom facesContext
* A custom servlet which forwards to the FacesServlet
(getServletContext().getRequestDispatcher(jsfPath).forward(req, res);)
* The FacesServlet which creates a facesContext too

I tried a custom FacesContextFactory which checks if there is already a
facesContext and returns it if this is the case.
It turned out that this can not work as the
servletRequest/servletResponse objects from the filter are not the same
as the one the FacesServlet sees.
In the end the forward did not work due to the fact that the JSF system
still sees the values from the Req/Rep objects hold by the custom
FacesContext from the filter.

I solved it with a custom FacesContext factory by checking to see if
there is a previous context .... and if so ... get some of its values
(locale/messages) and put them to the new facesContext.

If we think this is of any use for someone else with such an "exotic"
setup I can add the code to the sandbox or a wiki page.

Ciao,
Mario


Re: FacesServlet and preconfigured FacesContext

Posted by Matthias Wessendorf <ma...@apache.org>.
perhaps the FacesCtxFactory should check that ?

On 3/28/07, Mario Ivankovits <ma...@ops.co.at> wrote:
> Hi!
>
> I create my own FacesContext in an ServletFilter (in the end around the
> FacesServlet).
>
> The FacesServlet itself too creates a FacesContext.
>
> In the end I have some problems with this setup as the Faces Messages
> added to my FacesContext are never shown as the JSF system will use the
> FacesContext created by the FacesServlet.
>
> The question is:
> Shouldn't the FacesServlet check if there is a FacesContext and use this
> one instead of creating a new one?
> What do the RI do?
>
> Ciao,
> Mario
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com