How can I call / access a managed bean resource when the bean name is known but not yet built?
For instance:
<p:selectOneMenu value="#{eval.evaluateAsBean(bean).text}" >
<f:selectItems value="#{eval.evaluateAsBean(bean).values}" var="val"
itemLabel="#{val}" itemValue="#{val}" />
</p:selectOneMenu>
If there is a managed bean called testBean, and in my view the bean has a value "testBean", I want the text or values ββtestBean property to be called.
EDIT1
Context
An object consists of a list of properties (values). One property is modified using a special JSF editor, depending on its type.
The list of editors is determined by the type of object and displayed in the form using tags custom:include. This custom tag is used to dynamically enable editors <custom:include src="#{editor.component}">. The component property indicates the location of the JSF editor.
( ) (dynamicDropdown.xhtml). bean. facelet beans bean dynamicDropdown.xhtml bean.
genericAccount.xhtml
<p:dataTable value="#{group.editors}" var="editor">
<p:column headerText="Key">
<h:outputText value="#{editor.name}" />
</p:column>
<p:column headerText="Value">
<h:panelGroup rendered="#{not editor.href}">
<h:outputText value="#{editor.component}" escape="false" />
</h:panelGroup>
<h:panelGroup rendered="#{editor.href}">
<custom:include src="#{editor.component}">
<ui:param name="bean" value="#{editor.bean}"/>
<custom:include>
</h:panelGroup>
</p:column>
</p:dataTable>
#{editor.component} dynamicDropdown.xhtml.
dynamicDropdown.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<p:selectOneMenu value="#{eval.evaluateAsBean(bean).text}" >
<f:selectItems value="#{eval.evaluateAsBean(bean).values}" var="val"
itemLabel="#{val}" itemValue="#{val}" />
</p:selectOneMenu>
</ui:composition>
eval - bean:
@ManagedBean(name = "eval")
@ApplicationScoped
public class ELEvaluator {
...
public Object evaluateAsBean(String el) {
FacesContext context = FacesContext.getCurrentInstance();
Object bean = context.getELContext()
.getELResolver().getValue(context.getELContext(), null, el);
return bean;
}
...
}