0 Replies Latest reply on Mar 4, 2010 11:12 PM by Immo Benjes

    Problems with dynamic values in EL expressions

    Immo Benjes Newbie


      I've got a generic table where the user can select which columns are visible.
      The JSF part looks like this (as part of a table):

      <rich:columns id="#{column.id}" value="#{columns}" label="#{column.label}" var="column" index="ind" sortable="true" sortBy="#{data[column.value]}" sortOrder="#{column.sortOrder}" rendered="#{column.rendered}">
                <f:facet name="header">
                <s:fragment rendered="#{column.dataType eq 'java.lang.String'}">
                <s:fragment rendered="#{column.dataType eq 'java.lang.Boolean'}">
                            #{data[column.value] ? 'Yes' : 'No'}
                <s:fragment rendered="#{column.dataType eq 'java.util.Date'}">
                            <h:outputText value="#{data[column.value]}">
                                 <s:convertDateTime pattern="#{userProfile.dateFormat}"/>

      The column is a Bean which defines the column label, sorting order and which member of the actual data object (in most cases an entity) is shown in that row/column via


      On the java side you would define the column with something like

      new Column(1,"Column Label","memberName");

      with memberName being the member of the entity you want to show in that column.
      So in the JSF page you would get


      . That all works fine when you only want to access members in the entity. But e.g. you have a Object Company in the entity and that Company class has a member String companyName. You don't want to show Company in the data table but company.companyName

      The problem is if you specify

      new Column(1/*index*/,"Column Label","company.companyName");

      You get

      sortBy="#{data[column.value]}": Property 'company.companyName' not found on type XXX

      I've tried:


      all with no success. It seems you can't really nest EL expressions. Do you know a way to do it?

      I then tried to write my own tag handler (see here:

      and do


      but that doesn't work either.

      Any suggestions? My last resort is to have a method
      getObj(Object data)
      on Column which uses Reflection to find the right members but there must be a better way.