Using Session Bean provided data on JSF welcome page

Posted by takachgeza on Stack Overflow See other posts from Stack Overflow or by takachgeza
Published on 2010-03-25T23:04:29Z Indexed on 2010/03/25 23:33 UTC
Read the original article Hit count: 304

Filed under:
|
|

I use JSF managed beans calling EJB methods that are provide data from database. I want to use some data already on the welcome page of the application. What is the best solution for it?

EJBs are injected into JSF managed beans and it looks like the injection is done after executing the constructor. So I am not able to call EJB methods in the constructor.

The normal place for EJB call is in the JSF action methods but how to call such a method prior to loding the first page of the application?

A possible solution would be to call the EJB method conditionally in a getter that is used on the welcome page, for example:

public List getProductList(){
  if (this.productList == null) 
    this.productList = myEJB.getProductList();
  return this.productList;
}

Is there any better solution? For example, in some config file?

© Stack Overflow or respective owner

Related posts about jsf

Related posts about ejb3