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>