On 2/20/07, Steve Torrefranca <[EMAIL PROTECTED]> wrote:
 > Does it have to be a managed bean?
I am afraid so, though i could be wrong.  The List is used by the view
as source for select Items.  But yes I can use this a work around.


It's not really a "workaround".

The only thing special about managed beans are the fact that they can
get created for you, as a side effect of evaluating an expression.
But after creation the server actually puts them into one of the
normal scopes:

* Request scoped managed bean --> request attribute

* Session scoped managed bean --> session attribute

* Application scoped managed bean --> ServletContext attribute

Therefore, using a ServletContextListener to preinitialize your
application scoped managed bean is fine ... all you have to ensure is
that the attribute name you store it under is the same as the managed
bean name.  Later on, then, the managed bean facility will find that
the bean already exists, so it will not bother to create it.

Craig



Thanks man!

-Steve




Simon Lessard wrote:
> Hello Steve,
>
> Does it have to be a managed bean? You could probably chose a class
> with static methods instead and have the context listener initialize
> it upon application startup. You could then create a really
> lightweight application bean extracting its data from that class with
> static members. Forcing a bean into existence at application startup
> can be extremelly hard as JSF VariableResolver requires a FacesContext
> instance which is based on a request that you won't have inside the
> listener to evaluate a value.
>
>
> Regards,
>
> ~ Simon
>
> On 2/20/07, *Steve Torrefranca* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Hows that may I ask?  A getter needs to be called in order to
>     populate a
>     List that is DB driven
>
>     List theList = null;
>
>     public List getTheList(){
>         if(theList == null)
>            theList = getTheListFromDB();
>
>         return theList;
>     }
>
>
>
>
>     David Delbecq wrote:
>     > a webapp context listener
>     > En l'instant précis du 02/20/07 15:28, Steve Torrefranca
>     s'exprimait en
>     > ces termes:
>     >
>     >> what is the best way to do this?
>     >>
>     >> thank you
>     >>
>     >> -Steve
>     >>
>     >
>     >
>     >
>
>


Reply via email to