Search code examples
jsffaceletsmanaged-bean

How ManagedBeans figure out to which facelet or xhtml file they belong?


In JSF, I wonder how a ManagedBean understands that it should be available to an xhtml or facelet ?


Solution

  • To bind component values and objects to managed bean properties or to reference managed bean methods from component tags, page authors should use the Expression Language syntax. When user make request to the page that contains EL, that refers to specific manage bean, this bean will be instantiated by JSF framework (except managed beans that have attribute eager="true", that means that managed bean is created before it is requested for the first time). So the fact is that managed bean will be instantiated by JSF container and works as a model for the appropriate UI Component so the Facelet will know about the Bean, not vice versa