Is there a way to specify a managed bean used in EL at runtime and not design time? E.g.
actionListener=\"#{myBean.method}\"
such that myBean
part
If your question refers to generating a set of pages for a number of subclasses with common elements you can also use page composition to achieve this.
For example if Resident and NonResident are managed beans for subclasses of Person:
eg. in 'non-resident.xhtml'
<ui:define name="body">
<ui:param name="Controller" value="#{NonResident}"/>
<ui:include src="anyone.xhtml"/>
</ui:define>
and in 'resident.xhtml'
<ui:define name="body">
<ui:param name="Controller" value="#{Resident}"/>
<ui:include src="anyone.xhtml"/>
</ui:define>
then 'anyone.xhtml' can define the common elements using 'Controller' for the bean name.
This approach also enables you to eliminate duplicate page definition.
If you know the bean scope beforehand and the bean is already created beforehand, then yes, it's possible using the following syntax:
actionListener="#{requestScope[beanName].method}"
where #{requestScope}
represents the request scope map (same maps are available for view, session and application scopes) and #{beanName}
represents the variable holding the managed bean name.
If you don't know the bean scope beforehand and/or when the bean isn't created beforehand, then you'd need to create an utility EL function which does an Application#evaluateExpressionGet(), so that it can be used something like as follows:
actionListener="#{util:getBean(beanName).method}"