You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mike Kienenberger <mk...@gmail.com> on 2005/11/01 20:01:40 UTC

Re: Something is missing in JSF?

Yes, to summarize that thread:

Shale's ViewController wasn't intended to provide a generic managed
bean facility and is limited in what it provides.   It's probably not
what you want unless you have a single page-scoped bean you want to
manage.

If you're already using spring (or want to use Spring), the jsf-spring
integration library + Spring will provide this functionality.  
Implement InitializingBean and use afterPropertiesSet() instead of
init().

You can also create a "setInitialize()" setter as the last listed
managed bean property, and it's guaranteed to be called after all
previous properties are set.   This doesn't depend on any other
libraries, and can be used with any JSF implementation.   Thanks to
Simon for pointing this out.


On 10/30/05, Rick Gruber-Riemer <ri...@vanosten.net> wrote:
> You might as well read the thread "Providing spring-like
> InitializingBean interface for JSF managed beans" on 28-10-2005
> Martin Marinschek wrote:
> > Look at Craig's struts-shale.
> >
> > It's an add on library for JSF that provides features like this.
> >
> > regards,
> >
> > Martin
> >
> > On 10/30/05, Yee CN <ye...@streamyx.com> wrote:
> >
> >>
> >> 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
> >>
> >>
> >>
> >
> >
> > --
> >
> > http://www.irian.at
> > Your JSF powerhouse -
> > JSF Trainings in English and German
> >
>
>