2

2 つの配列リストがあります。従業員リストと割り当てリスト。

各従業員には割り当てリストがあります。

Employeeクラスは以下の通り。

public class Employee {

    private int id;   
    private String firstname;

    private String lastname;

    private List<Allocation> allocationList ; 

    // geters and setters

}

Allocationクラスは次のとおりです

public class Allocation {

    private int categoryId;

    private String categoryName;

    private float allocation;

    // getters and setters

}

X、Y、Z という名前の 3 つの割り当てカテゴリがあるとします。

各従業員は、これらの各カテゴリに対応する値を持っています。

従業員の erik は、X = 10、Y = 20、Z = 67 などです。

次の図に示すように、表示タグを使用して、従業員の詳細と従業員ごとの割り当てを表示するにはどうすればよいですか。

ここに画像の説明を入力

ネストされたリストは表示タグでエクスポートされないため、ネストされたリストを表示できるディスプレイタグのネストされたテーブル機能を使用したくありません。

4

1 に答える 1

3

Ok。だから私は自分でそれを理解しました。以下は作業コードです。

<display:table name="employeeList" pagesize="25" class="listingTable" keepStatus="true" cellpadding="0px"
  cellspacing="0px" id="employee" export="true" requestURI="">
  <display:setProperty name="export.decorated" value="true" />
  <display:setProperty name="export.excel.filename" value="${exportFileName}.xls" />

  <c:forEach var="cl" items="${selectedColumnList}">
    <display:column property="${cl.property}" title="${cl.title}" format="${cl.format}" />
  </c:forEach>

  <c:forEach var="allocationCl" items="${allocationCategoryList}" varStatus="status">
    <c:set var="allocationCounter" value="${status.index}" />
    <display:column title="${allocationCl.category}">
      <c:choose>
        <c:when test="${fn:length(employee.allocations) ne '0' }">
      ${employee.allocations[allocationCounter].allocation}
    </c:when>
        <c:otherwise>
      0
    </c:otherwise>
      </c:choose>
    </display:column>
  </c:forEach>

  <display:setProperty name="paging.banner.item_name" value="Employee" />
  <display:setProperty name="paging.banner.items_name" value="Employees" />
</display:table>
于 2012-07-06T09:23:29.697 に答える