I have a table on which I can select several rows using a checkbox
that would be the column selector
:
<p:dataTable value="#{cityBean.cities}" var="city" id="dt_cities" widgetVar="w_cities"
filteredValue="#{cityBean.filteredCities}"
selection="#{cityBean.selectedCities}"
rowKey="#{city.id}"
rowSelectMode="add"
scrollable="true" scrollHeight="300">
<p:column id="selector" selectionMode="multiple" style="text-align:center" />
<p:column headerText="Name" sortBy="#{city.name}" filterBy="#{city.name}" filterMatchMode="contains">
<h:outputText value="#{city.name}" />
</p:column>
</p:dataTable>
Then I have two buttons with which I can export the selected rows (using selectionOnly="true"
) in two ways: XLS
or PDF
.
<h:commandLink >
<p:graphicImage url="#{resource['icons/excel_exports.png']}" />
<p:dataExporter type="xls" target="dt_cities" fileName="list_cities" selectionOnly="true" />
</h:commandLink>
<h:commandLink>
<p:graphicImage url="#{resource['icons/pdf_exports.png']}" />
<p:dataExporter type="pdf" preProcessor="#{cityBean.pdfLandscape}"
target="dt_cities" fileName="list_cities"
selectionOnly="true"/>
</h:commandLink>
The bug
with which I find myself is that for example: I have a list of 10 elementos
numbered% of 1 al 10
, I select the elements 9, 8, 5 y 2
. When clicking on the export buttons, 4 elementos
appears but they do not correspond to your selection, the 1, 2, 3 y 4
elements appear.
Recognizes how many elements are selected but can not interpret what they are.
I am currently using: JSF 2.2
and Primefaces 5.1 RC1
.