Got this design issue with JSF + Spring :-
I got a datatable on a page to be loaded showing user details, which is to be fetched form Database.
So my jsf page has :
<p:dataTable id="userTable" var="user" value="#{userBean.users}" rowKey="#{user.userID}"
selection="#{userBean.selectedUser}" paginator="true" rows="10" >
Managed bean has:
private List<UserDetails> users; // getters and setters
Now my managed bean needs a spring injection of the helper class to fetch the users from DB.
@ManagedProperty(value="#{userBO}")
private UserBO userBO;
The problem is , spring injection happens when the object is completely instantiated. So I cannot place my userBO.getUsersFromDataBase() in the constructor and assign it to my users
I just can’t figure out how to fetch users from DB,using spring injection in my managedBean. Spring needs the instantiation of the ManagedBean to be complete so that it can inject the helper class, but the jsf page requests the database values much before the ManagedBean is completely instantiated. Kinda stuck :/
I am not familiar with spring, however in standard JSF you can use the
@PostConstructannotation on a method that will be invoked after construction and after dependency injection, e.g.: