webtier@glassfish.java.net

JSF 2.0: ManagedBean not quite there...

From: <webtier_at_javadesktop.org>
Date: Sun, 04 Jan 2009 16:53:14 PST

I'm still engaged in my test JSF 2 application; same one I referred to in a prior thread. Most things are working out fine.

As an aside there are odd quirks. For example, System.out.println's in the handleNavigation method of a custom NavigationHandler do not print out, although the method is indisputably being called, and is correctly doing its thing. This had (has) me baffled. :-) No indication of any standard stream redirection in the 2.0.0-PR source, so who knows?

In any case, the curiosity at hand is this. I have 2 managed beans (@ManagedBean), both request scope (@RequestScoped), both having one method and several regular properties, and each having one managed property (@ManagedProperty). Both also have a @PostConstruct initialization method. There is nothing in the faces-config.xml except for a different navigation handler.

Both managed beans must be instantiated when you call associated Facelets pages, because of value bindings. One of the managed beans is operating just fine - I can see that from the page, but also because of printouts in its constructor and @PostConstruct method.

However, the other managed bean (judging by the System.out.println's in its ctor and @PostConstruct) never gets instantiated at all. However, the association between the EL variable and the managed bean has been correctly made, as per:

javax.el.PropertyNotFoundException: /main/welcome.xhtml @14,77 value="#{welcome.version}": The class 'org.ahs.beans.WelcomeBean' does not have the property 'version'.

So pretty clearly the @ManagedBean annotation on this troublesome class did get processed.

I've also varied the order in which I access these pages. It makes no difference.

I'm hoping there's something very obvious causing this. I've been staring at it too much; near as I can tell these are identically set up beans (except for the fact that the successful one also has a working @EJB injection happening).

Regards,
Arved Sandstrom
[Message sent by forum member 'arveds' (arveds)]

http://forums.java.net/jive/thread.jspa?messageID=324005