0
votes

In JSF we can inject one @ManagedBean in to another using @ManagedProperty.
My questions regarding that are:

  • Can I Inject a ManagedBean or ManagedProperty in to another Normal Java Bean class?

  • Are there any restrictions on ManagedProperty injection based on scope of the bean? for example: can i Inject @RequestScoped Bean or Property into to @ViewScoped bean?

  • Are there any other methods to access the @ManagedBean instances and their properties other than @ManagedPropery?

Please point me to the link if any of the above questions are already discussed?

1

1 Answers

2
votes
  1. Definitely no, you only can access them via FacesContext if your current class is not managed by JSF session.
  2. There are. You only can set a managed bean which has a wider scope. That makes sense, cause there's no reason for a bean with @SessionScope, for example, to contain explicit info about a @RequestScoped bean. However, you could access some session info from your request scoped bean if you do it in the other way.
  3. Referring to this last question you can get the managed beans from your context in several ways.