Here's a mini example:
public class Cache
{
private static List myList;
public static void init(Object... someParameters)
{
myList = getTheListFromDB();
}
public static List getList()
{
return myList;
}
}
public class ApplicationBean
{
public List getList()
{
return Cache.getList();
}
}
public class MyServletContextListener implements ServletContextListener
{
public void contextInitialized(ServletContextEvent ev)
{
Cache.init(ev.getServletContext
().getInitParameter("MyDBConnectionInfoOrJNDIName"));
}
}
Regards,
~ Simon
On 2/20/07, Simon Lessard <[EMAIL PROTECTED]> 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]> 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
> >>
> >
> >
> >
>
>