Hi,

 

I am having problem finding a solution for a simple task that I have done a hundred times in ASP.NET. Let me illustrate a scenario:

 

Backing bean: UserBean

The bean is to have an init() method which looks for the request parameter “userId”, loads the user for display in viewUser.jsf.

It makes use of UserService to load the user from database. The UserService is injected by Spring.

 

The problem:

The logical place to call init() is in UserBean constructor – but Spring does not inject UserService until AFTER the bean is constructed. So the constructor is out.

 

Where else could I do it? At the setUserService setter method? That would work – however what if I need Spring to inject more than 1 object, which setter should I place init()? This approach is down right ugly anyway.

 

Do I need to implement phase listener (I do not fully understand how that works yet)?

 

Am I missing something? Or is something missing in JSF?

 

Many thanks in advance.

 

Regards,

Yee

 

Reply via email to