File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes More than one ManagedProperty ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "More than one ManagedProperty ?" Watch "More than one ManagedProperty ?" New topic

More than one ManagedProperty ?

michael nik

Joined: Mar 11, 2012
Posts: 15
I have the following beans:

Also, I am using a property to use the above bean in my second class named

Everything is working properly. Now, something is going wrong in my class when I add a second bean property e.g @ManagedProperty(value="#{mybean3}") from a third class

Is it feasible to happen, to whit having 2 different @ManagedProperty values in a third class ?

Thank you
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17247

I do much more complex things than that routinely.

However, I see two issues:

1. You have a ManagedBean, but the ManagedBean and SessionScoped annotations are not made on the class definition, but rather inside the class body. I'm surprised that the compiler didn't outright reject that.

2. When you have a managed property, that property required an explicit public setter method according to the JavaBeans convention. Id est, you cannot call it "setUser1" and expect JSF to find it - it has to be named "setMybean1. The mybean1 property gains nothing from being declared public. Except that doing so means that application logic could could directly modify its value without going through a common mutator. JSF, however, will not. It requires the "set" method.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: More than one ManagedProperty ?
It's not a secret anymore!