Hi,
I am working on a very dynamic UI and am stuck on a problem using EL in a facelets view.
JBoss 5.0.x
RichFaces 3.2.x
JSF 1.2
Facelets 1.1.x
Java 1.6
In the below code I'm trying to bind a variable but the expression path to the bean/variable is dynamic:
myList is a ListDataModel that is passed in as a variable. For example it may be from
myBean1.customerList;
myColumns is a list of meta data Objecst that is also passed in, has information about the column and binding. For example
column1.headerTxt = "Customer Name"
column1.relativePathToProperty = "name"
el:setValueBinding is a custom tag that sets a value binding
This code works for this scenario:
<rich:dataTable var="listItem" value="#{myList}">
<c:forEach var="column" items="#{myColumns}">
<el:setValueBinding var="property"
valueBinding="${column.relativePathToProperty}" />
<rich:column>
<f:facet name="header">
<h:outputText value="#{column.headerTxt}" />
</f:facet>
<h:inputText value="#{listItem[property]}" />
</rich:column>
</c:forEach>
</rich:dataTable>
However if the meta data is
column2.headerTxt = "Zip Code"
column2.relativePathToProperty = "address.zipCode"
This does not work. Basically it only supports one level deep of property mappings by using "listItem[property]" but that method breaks down if the item being iterated over in the table has depth that you want to bind to. What I need is some mechanism to combine
listItem + "address.zipCode" so that an EL expression would call "customer.getAddress().getZipCode()".
The challenge seems to be that I cannot access listItem until within the defferred context ("# annotation") but cannot dynamically resolve properties unless using the immediate context "($ annotation)", and I'm at a loss for the approach to accomplish this. Any ideas are greatly appreciated...?