Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More than one ManagedProperty ?

 
michael nik
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following beans:



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




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

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

Thank you
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic