Mario Ivankovits wrote:
Mike Kienenberger wrote:
Thanks. I hadn't considered the possibility that this wasn't a
managed bean.
So if it's an unmanaged bean, it sounds like it's better to work with
the Map directly, but if it is a managed bean you probably don't want
to do that since the bean may not exist yet.
But as long as the bean is managed, I dont understand why all this
resolver stuff is recommended instead of the manager-property stuff?
As long as you are able to avoid any faces specific stuff in your bean
its easier to reuse such a bean, isnt it?
Do you mean that it seems easier to just grab the object from the
request or session map than look it up via the myfaces variable
resolver? As was noted, doing a lookup in the map will not trigger
creation of the bean; you get null if it doesn't already exist.
Sometimes this is desirable, sometimes not.
Or do you mean that using the faces-config.xml file to specify
dependency injection is better than explicitly looking up stuff using
faces-specific code? I certainly agree with this, with the point that it
keeps the target class free of JSF-specific code being a very important
one. But that's a matter of taste that not everyone shares; both
approaches are technically valid. I did list the "injection" solution
first on the wiki in the hope it would prod people towards using that
solution :-)
Cheers,
Simon
- Re: Accessing a session-scoped backingbean Simon Kitching
-