-->

How to use DisplayTag with nested Lists and Proper

2019-08-05 05:30发布

问题:

I'm trying to display a list. Inside this list there is another list which I want to display. With Struts my code looked like this:

<s:iterator value="lendingList">
    <tr>
        <td><s:property value="lendBy.matNumber" /> <s:property
                value="lendBy.firstName" /> <s:property value="lendBy.name" /></td>
        <td><s:property value="date" /></td>
        <td><s:iterator value="publication">
                <s:property value="isbn" />
            </s:iterator></td>
        <td><s:iterator value="publication">
                <s:property value="title" />
            </s:iterator></td>
        <td><s:property value="returnDate" /></td>
        <td><s:property value="remindProcessStarted" /></td>

The new DisplayTag Table looks like this:

<display:table id="lendingList" name="lendingList" pagesize="6"
    cellpadding="5px;" cellspacing="5px;"
    style="margin-left:50px;margin-top:20px;" requestURI="" sort="list">
    <display:column property="lendBy.matNumber" title="Mat.-Nr."
        sortable="true" />
    <display:column property="lendBy.firstName" title="Nachname"
        sortable="true" />
    <display:column property="lendBy.name" title="Vorname" sortable="true" />
    <display:column property="publication.isbn" title="Vorname" sortable="true" />
    <display:column property="publication.title" title="Vorname" sortable="true" />
    <display:column property="returnDate" title="Rückgabedatum"
        sortable="true" />

</display:table>

I tried to access the properties with publication.isbn, but unfortunately it is not working. I couldn't find any hints in the documentation.

回答1:

The problem was that I had to give a uid to the table, after that I can access the properties with a Struts iterator like this:

<display:column media="html" title="Titel" sortable="true">
    <s:iterator value="#attr.lendingList.publication">
        <s:property value="title" />
    </s:iterator>
</display:column>