1

We created a JSF table component for our projects which uses <ui:repeat> to create the table. A new requirement to add a table inside a table (the second table resides in a row and is collapsable) has gotten us into trouble as the <ui:repeat var="row" ...> is set statically inside the table componenten and the inner table uses the row variable of the outer table when iterating through the list. Now what i want to create is something like this:

<div>
   <myfw:mytable dataModel="#{bean.user}" varName="user" ...>
      <myfw:mycolumn value="#{user.name}"/>
      <myfw:myexpendablecolumn>
         <myfw:mytable dataModel="#{bean.acl}" varName="acl" ...>
            <myfw:mycolumn value="#{acl.name}"/>    
         </myfw:mytable>
      </myfw:myexpendablecolumn>
   </myfw:mytable>
</div>

In the table component the var attribute should be set ...

<composite:interface>
...
    <composite:attribute name="varName" required="false"
        type="java.lang.String" default="row" />
</composite:interface>

<composite:implementation>
...

        <ui:repeat var="#{varName}" value="#{cc.attrs.dataModel.wrappedData}"
            varStatus="loop">
            <div class="floating_table_row">
                              <composite:insertChildren />  
            </div>
        </ui:repeat>
</composite:implementation>

... but sadly, this does not work. I've tried it with <c:forEach> but the result is the same, the values of the columns are empty and no data is shown. Is there a way to dynamically set the var attribut of the <ui:repeat>?

Patrick
  • 55
  • 1
  • 7

1 Answers1

1

After further research I stumbled over this page https://java.net/jira/browse/FACELETS-372 where the UIRepeat class, specifically the getVar method is modified to access the ValueExpression so instead of

public String getVar() {
    return this.var;
}

... the method looks like this:

public String getVar() {
    if (this.var != null) {
        return this.var;
    }
    ValueExpression ve = this.getValueExpression("var");
    if (ve != null) {
        return (String) ve.getValue(getFacesContext().getELContext());
    }
    return null;
}

There are further modifications in the attached file from https://java.net/jira/browse/FACELETS-372. Sadly, the UIRepeatclass cannot be simply extended because of the usage of the var attribute in private methods so I now have a <myfw:repeat> which utilises the patched UIRepeat class from the page.

John Yeary
  • 1,112
  • 22
  • 45
Patrick
  • 55
  • 1
  • 7