Michał Piątkowski
Michał Piątkowski

Reputation: 363

Export to xml in from p:dataTable is not working

I have a problem with PrimeFaces. I can't export any data from datatable to xml file. On each try I am getting same error: javax.faces.FacesException: No suitable xml tag found for org.primefaces.component.column.Column@79879de5

Code of datatable:

<p:dataTable id="Codes" var="code" value="#{codesTable.allCodesFromDB}" selection="#{codesTable.selectedCodes}" rowKey="#{code.id}"
    paginatorTemplate="{CurrentPageReport}  {FirstPageLink}
           {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
        rowSelectMode="checkbox"
        paginator="true" rows="15" style="margin-bottom:20px">
    <f:facet name="{Exporters}">
        <div class="inline-block">
            <h:commandLink>
                <img src="resource/img/csv-icon.png" alt="" class="exporter-icon img-responsive"/>
                <p:dataExporter type="csv" target="Codes" fileName="kody" selectionOnly="true"/>
            </h:commandLink>
        </div>
        <div class="inline-block">
            <h:commandLink>
                <img src="resource/img/xml-icon.png" alt="" class="exporter-icon img-responsive"/>
                <p:dataExporter type="xml" target="Codes" fileName="kody2" selectionOnly="true" />
            </h:commandLink>
        </div>
    </f:facet>
    <p:column selectionMode="multiple" style="width:50px;text-align:center"/>
    <p:column sortBy="#{code.id}">
        <f:facet name="header">
            <h:outputText value="Id" />
        </f:facet>
        <h:outputText value="#{code.id}" />
    </p:column>

    <p:column sortBy="#{code.code}">
        <f:facet name="header">
            <h:outputText value="Kod"/>
        </f:facet>
            <h:outputText value="#{code.code}" />
    </p:column>

    <p:column sortBy="#{code.companyName}">
        <f:facet name="header">
            <h:outputText value="Nazwa firmy" />
        </f:facet>
            <h:outputText value="#{code.companyName}" />
    </p:column>

    <p:column sortBy="#{code.codesQuantity}">
        <f:facet name="header">
            <h:outputText value="Ilość" />
        </f:facet>
            <h:outputText value="#{code.codesQuantity}" />
    </p:column>

    <p:column sortBy="#{code.formattedStringOfDate}">
        <f:facet name="header">
            <h:outputText value="Data" />
        </f:facet>
            <h:outputText value="#{code.formattedStringOfDate}" />
    </p:column>

    <f:facet name="footer">
        <p:commandButton process="Codes" icon="ui-icon-search" value="Usuń" actionListener="#{codesTable.removeCodesFromDB()}"
                update=":tableDataFormCodes:Codes"/>
    </f:facet>
</p:dataTable>

CSV export is normally working and when I try to export XML with no rows selected, program is generating file. I tried newest version and 5.2, both are not working. I am using glassfish server.

Upvotes: 0

Views: 748

Answers (1)

Apostolos
Apostolos

Reputation: 10498

The problem is with the selection column.

<p:column selectionMode="multiple" style="width:50px;text-align:center"/>. 

remove it and it should work or add a facet header to it.

See the source code here

Upvotes: 2

Related Questions