myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mathieu fabre" <mathieu...@gmail.com>
Subject Re: question about managed bean
Date Thu, 20 Mar 2008 11:04:20 GMT
Indeed, it is the application-scope bean.

Thanks you for your answer which is clear and complete.
I will try the third solution.

Thanks again,

Mat

2008/3/20, simon.kitching@chello.at <simon.kitching@chello.at>:
>
> mathieu fabre schrieb:
>
> > Hi,
> >
> > I use JSF and MyFace in a webapp. I use some managed bean ( declared
> > in the
> > face-config.xml)
> > I would like to know if it's possible to create a managed bean at the
> > begining (like a tag <load-on-startup> we can use in servlet)
> > and not only when requested for the first time...
>
>
> Not with the standard JSF managed-beans functionality.
>
> I presume that this is an application-scope bean (anything else would
> not make sense to create on startup). In this case, you could use a
> servlet or servlet-context-listener to just add an entry into the
> standard application scope for the webapp; a JSF EL expression will find
> it there if it exists even though it is not defined as a managed-bean in
> the faces-config.xml file.
>
> If you really want to define it in the faces-config.xml file (eg to
> configure it via dependency injection) then it is possible by having a
> ServletContextListener that sets up a FacesContext instance, then loads
> the bean manually. But that is not trivial.
>
> But the easiest solution of all would be to use Spring to define your
> managed beans rather than the JSF built-in managed-beans configuration.
> This gives a whole lot of really useful features, one of which is the
> ability to create beans on startup. There is a page on the myfaces wiki
> about this:
>   http://wiki.apache.org/myfaces/JSF_With_Spring
>
> Regards,
>
> Simon
>
>

Mime
View raw message