You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Yee CN <ye...@streamyx.com> on 2006/01/20 17:38:13 UTC
How to create a managed bean outside of JSF
Hi,
Is there are way to get hold of JSF bean factory and instantiate managed
beans outside of JSF?
My reason for asking is that I have spring IOC for business tier, JSF IOC
for web tier, + jsf-spring integration. My web tier also contains helper
classes for servlets that I need to inject dependencies from the business
tier. I like to keep spring's applicationContext exclusive to the business &
persistent tier, so my next best bet is to place them under JSF managed
beans.
Or is there a better approach?
Many thanks in advance.
Yee
Re: How to create a managed bean outside of JSF
Posted by Andrew Robinson <an...@gmail.com>.
If the faces context is active (there is a currently processing facelets
request), you can just use the static methods on the faces context to get
the current context, and use the standard JSF APIs for injecting information
into the session/request/page, etc. I have been able to get beans and such
from non-JSF code in the past by using the faces context. Just make sure
that a faces context has indeed been started for your request.
On 1/20/06, Yee CN <ye...@streamyx.com> wrote:
>
> Hi,
>
>
>
> Is there are way to get hold of JSF bean factory and instantiate managed
> beans outside of JSF?
>
>
>
> My reason for asking is that I have spring IOC for business tier, JSF IOC
> for web tier, + jsf-spring integration. My web tier also contains helper
> classes for servlets that I need to inject dependencies from the business
> tier. I like to keep spring's applicationContext exclusive to the business &
> persistent tier, so my next best bet is to place them under JSF managed
> beans.
>
>
>
> Or is there a better approach?
>
>
>
> Many thanks in advance.
>
> Yee
>