You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Carl Sziebert <ca...@vegas.com> on 2006/06/05 19:11:16 UTC
Managed bean lookup from servlet filter?
Hi all:
I'm trying to access a managed bean from a servlet filter. The filter
is defined to wrap the '*.jsf' url pattern. My code to do the lookup
functions something like this:
getApplication().createValueBinding("#{myBean}").getValue(FacesContext.g
etCurrentInstance())
And my bean mapping looks like this:
<managed-bean>
<managed-bean-name>myBean</managed-bean-name>
<managed-bean-class>com.vegas.MyBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
Unfortunately the FacesContext is null in all cases. Is there a better
way to do this? Is lookup of a managed bean from a filter even
possible?
Thanks in advance.
Carl
Re: Managed bean lookup from servlet filter?
Posted by Murat Hazer <mu...@gmail.com>.
Can't you use Phase Listener instead of servlet filter?
regards...
On 6/5/06, Val Blant <va...@yahoo.ca> wrote:
>
>
> Try this in your doFIlter():
>
> FacesContextFactory contextFactory = (FacesContextFactory)
> FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
> LifecycleFactory lifecycleFactory = (LifecycleFactory)
> FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
> Lifecycle lifecycle =
> lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
>
> FacesContext facesContext = contextFactory.getFacesContext(servletContext,
> request, response, lifecycle);
>
> Let me know if it works.
> --
> View this message in context:
> http://www.nabble.com/Managed-bean-lookup-from-servlet-filter--t1736402.html#a4718698
> Sent from the MyFaces - Users forum at Nabble.com.
>
>
--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
Re: Managed bean lookup from servlet filter?
Posted by Val Blant <va...@yahoo.ca>.
Try this in your doFIlter():
FacesContextFactory contextFactory = (FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle =
lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContext facesContext = contextFactory.getFacesContext(servletContext,
request, response, lifecycle);
Let me know if it works.
--
View this message in context: http://www.nabble.com/Managed-bean-lookup-from-servlet-filter--t1736402.html#a4718698
Sent from the MyFaces - Users forum at Nabble.com.