views:

63

answers:

1

I am using Spring Roo. There is table:table and table:column tags.

How to display sub-property of colections elements in table?

In straightforward way it doesnt work:

<table:table data="${knowledgebase.concepts}" id="l_domain_Concept" path="/concepts" z="user-managed">
  <table:column id="c_domain_Concept_translations" property="defaultTranslation.name"  z="user-managed" />
</table:table>

Exception:

Caused by: javax.el.PropertyNotFoundException: Property 'defaultTranslation.name' not found on type domain.data.Concept
A: 

I modified table.tagx so it could be used with sub-properties and Spring converting capabilities.

<c:forTokens items="${columnProperties}" delims="," var="column" varStatus="num">
<c:set var="prop" value="${ item }" />
    <c:forTokens items="${column}" delims="." var="subprop">
        <c:set var="prop" value="${ prop[subprop]}" />
    </c:forTokens>
<c:set var="columnMaxLength" value="${lengths[num.count - 1]}" scope="request"/>
 <td>
     <c:choose>
         <c:when test="${not convert}">
             <c:out value="${columnMaxLength lt 0 ? prop : fn:substring(prop, 0, columnMaxLength)}" />
         </c:when>
         <c:otherwise>
             <spring:eval expression="prop" />
     </c:otherwise>
     </c:choose>
 </td>

janis.abele