Using Printer or DataExporter in PrimeFaces Mobile

UI Components for JSF
Post Reply
tetamusha
Posts: 8
Joined: 17 Mar 2016, 06:16

23 Aug 2016, 02:08

I am trying to export data displayed in a PrimeFaces DataTable in an app made with PrimeFaces Mobile 6.0.

I created some buttons that use either the Printer component or the DataExporter compinent. In the DataExporter, I used all available file formats.

All buttons that call the DataExporter do nothing, no loading or other visible behavior. The button that calls the Printer actually prints the contents of the DataTable, but the formatting is different from the one displayed on screen. Also, I read here http://stackoverflow.com/questions/3012 ... hout-pagin that Printer needs a workaround when used in a DataTable with paginators, so I'd like to make the DataExporter work properly.

I have added iText and apache.commons.poi as dependencies, just as required by the DataExporter. Does anyone have any advice? Below is the code that contains the buttons and the table.

Code: Select all

<p:commandButton value="Excel" type="button" styleClass="ui-btn-inline">
    <p:dataExporter type="xls" target="tb_turmas" fileName="export" />
</p:commandButton>
<p:commandButton value="PDF" type="button" styleClass="ui-btn-inline">
    <p:dataExporter type="pdf" target="tb_turmas" fileName="export" />
</p:commandButton>
<p:commandButton value="CSV" type="button" styleClass="ui-btn-inline">
    <p:dataExporter type="csv" target="tb_turmas" fileName="export" />
</p:commandButton>
<p:commandButton value="XML" type="button" styleClass="ui-btn-inline">
    <p:dataExporter type="xml" target="tb_turmas" fileName="export" />
</p:commandButton>
<p:commandButton value="Imprimir" type="button" styleClass="ui-btn-inline">
    <p:printer target="tb_turmas" />
</p:commandButton>
<p:dataTable id="tb_turmas" var="turma" sortBy="#{turma.nome}"
             value="#{escolaInfoView.turmas}" rowKey="#{turma.id}"
             paginator="true" reflow="true" emptyMessage="Não há registros"
             tableStyleClass="ui-table-columntoggle">

    <p:column headerText="Nome" sortBy="#{turma.nome}">
        <h:link outcome="turmaInfo.xhtml?turmaId=#{turma.id}"
                value="#{turma.nome}" />
    </p:column>
    <p:column headerText="Alunos" sortBy="#{turma.nAlunos}">
        <h:outputText value="#{turma.nAlunos}" />
    </p:column>
    <p:column headerText="Provas Aplicadas" sortBy="#{turma.nAplicacoes}">
        <h:outputText value="#{turma.nAplicacoes}" />
    </p:column>
</p:dataTable>

tetamusha
Posts: 8
Joined: 17 Mar 2016, 06:16

23 Aug 2016, 02:34

I just saw my mistake. I was using type="button" in the buttons that called the DataExporters and that is not how things should be done.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 52 guests