Reputation: 743
Let's say we have a bean like
@ManagedBean(name = "categoriesbean")
@RequestScoped
public class CategoriesBean {
Integer id;
public Integer getId() { return id;}
public void setId(Integer idarg) { id = idarg;}
...
...
}
and in the same application, elsewhere I have
@ManagedBean(name = "categoriesdetailedbean")
@ViewScoped
public class CategoriesDetailedBean extends CategoriesBean {
Integer idderived;
public Integer getIdderived() { return idderived;}
public void setIdderived(Integer idderivedarg) { idderived = idderivedarg;}
...
...
}
What is the scope of "categoriesdetailedbean", and it's properties (such as scope of Id vs Idderived?).
The reason I ask is, I am seeing some effects which I can't seem to understand very well.
Upvotes: 0
Views: 210
Reputation: 1108712
The class annotations are specific to the class itself and they are discarded when you subclass it. Per saldo, you CategoriesDetailedBean
has inherited two methods getId()
and setId()
and that's all. They do not magically run in a different scope nor hold the values of a different instance.
You're not very clear about the concrete functional requirement, so it's hard to post a suitable answer to what you're really trying to do. But if I guess it right, you actually want to access a different managed bean instance from inside a managed bean. If so, then you can use @ManagedProperty
for this. Or perhaps you want a master-detail view and in this case you don't need to inject beans in each other, but better pass the detail ID as GET request parameter and use <f:viewParam>
to set it.
Upvotes: 1