2016-11-23 11 views
0

私はリストのリストを持っています。学生と住所を言うことができます。 1対多数の関係。私のデータテーブルには、学生に関連する名前、姓、年齢の3つの列があります.1つの列には、address1、address2、city、country.Nowのような次のフィールドを連結してアドレスを表示する必要があります。テーブル<p:dataExporter>を使用します。私はエクセルとしてエクスポートしようとするとアドレスの対応する列は、オブジェクト(org.primefaces.uirepeat。何とか何とか...)としてエクスポートされPrimefacesデータエクスポータ:データのエクスポート問題

私のコードは

<p:dataTable value="#{manager.studentList}" var="item" id="studentData"> 
      <p:column> 
       <f:facet name="header">Name</f:facet> 
       <h:outputText value="#{item.name}" /> 
      </p:column> 
      <p:column> 
       <f:facet name="header">Surname</f:facet> 
       <h:outputText value="#{item.surname}" /> 
      </p:column> 
      <p:column> 
       <f:facet name="header">Age</f:facet> 
       <h:outputText value="#{item.age}" /> 
      </p:column> 
      <p:column> 
       <f:facet name="header">Address</f:facet> 
       <ui:repeat value="#{studentBean.addressList}" var="address"> 
       <h:outputText value="#{address.address1}" /> <br /> 
       <h:outputText value="#{address.address2}" /> <br /> 
       <h:outputText value="#{address.city}" /> <br /> 
       <h:outputText value="#{address.country}" /> 
       </ui:repeat> 
      </p:column> 
     </p:dataTable> 

     <h:commandLink> 
     <p:graphicImage name="/images/excel.png" /> 
     <p:dataExporter type="xls" target="studentData" fileName="studentdetails" pageOnly="true"/> 
    </h:commandLink> 

である私にエクスポートするためのいくつかの方法を提案します。私はc:forEachと列を試してみました。

答えて

0
<p:dataTable value="#{manager.studentList}" rowIndexVar="index" var="item" id="studentData"> 
     <p:column> 
      <f:facet name="header">Name</f:facet> 
      <h:outputText value="#{item.name}" /> 
     </p:column> 
     <p:column> 
      <f:facet name="header">Surname</f:facet> 
      <h:outputText value="#{item.surname}" /> 
     </p:column> 
     <p:column> 
      <f:facet name="header">Age</f:facet> 
      <h:outputText value="#{item.age}" /> 
     </p:column> 
     <p:column> 
      <f:facet name="header">Address</f:facet> 
      <c:forEach var="address" items="#{studentBean.addressList.get(index).address}"> 
       <h:outputText value="#{address.address1}" />, 
       <h:outputText value="#{address.address2}"/>, 
       <h:outputText value="#{address.city}" />, 
       <h:outputText value="#{address.country}" /> 
      </c:forEach> 
     </p:column> 
    </p:dataTable> 

    <h:commandLink> 
    <p:graphicImage name="/images/excel.png" /> 
    <p:dataExporter type="xls" target="studentData" fileName="studentdetails" pageOnly="true"/> 
</h:commandLink> 

私はCとしよう:forEachのはOK

です
関連する問題