I would like to show different items of a list in my dataTable
I tried ui:repeat but it's seems not working
I have an object Demande(Classe demande) it has a list of Choix and I want to show for all demandes the choice and the periode(Classe Periode) of each choice(classe Choix)
<p:dataTable id="estivage" var="it" emptyMessage="Aucune demande !"
value="#{demandeController.allDemandes}" paginator="false" style="width: 800px"
rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header">
Liste des Demandes pour la periode d'éstivage
</f:facet>
<p:column style="text-align:center" sortBy="#{it.utilisateur.nom}">
<f:facet name="header">
<h:outputText value="Adherent" />
</f:facet>
<h:outputText value="#{it.utilisateur.nom}" />
<h:outputText value=" " />
<h:outputText value="#{it.utilisateur.prenom}" />
</p:column>
<p:column style="text-align:center" sortBy="#{it.dateDemande}">
<f:facet name="header">
<h:outputText value="Date de la demande" />
</f:facet>
<h:outputText value="#{it.dateDemande}">
<f:convertDateTime pattern="dd/MM/yyyy 'à' HH:mm:ss" />
</h:outputText>
</p:column>
<ui:repeat var="item" value="#{it.listChoix}">
<p:column style="text-align:center">
<f:facet name="header">
<h:outputText value="chalet " />
</f:facet>
<h:outputText value="#{item.chaletChoisi}" />
</p:column>
<p:column style="text-align:center">
<f:facet name="header">
<h:outputText value="periode " />
</f:facet>
<h:outputText value="#{item.periode.libelle}" />
</p:column>
</ui:repeat>
<p:column style="text-align:center">
<f:facet name="header">
<h:outputText value="Mode paiement" />
</f:facet>
<h:outputText value="#{it.modePaiement}">
</h:outputText>
</p:column>
</p:dataTable>
any help please
You have <p:column> in your ui:repeat. It doesn't work well. You could try SubTable from Primefaces.
See example from Primefaces Showcase:
http://www.primefaces.org/showcase/ui/datatableSubTable.jsf
The list of Choix for every Demandesyou can show then in SubTable.
Another possibility is if you use nested DataTables. Use a p:column of "estivage" table and define inside that column another datatable that shows the list of Choix.
<p:dataTable id="estivage" var="it">
<p:column header="choice and periode">
<p:dataTable var="item" value="#{it.listChoix}">
<p:column style="text-align:center">
<f:facet name="header">
<h:outputText value="chalet " />
</f:facet>
<h:outputText value="#{item.chaletChoisi}" />
</p:column>
<p:column style="text-align:center">
<f:facet name="header">
<h:outputText value="periode " />
</f:facet>
<h:outputText value="#{item.periode.libelle}" />
</p:column>
</p:dataTable>
</p:column>
</p:dataTable>
Related
I want my table headers to have the first value of my dataTable.
I know I can change the value of the headerText but for my project I need the header to change according to the values being output.
So from the picture I want 'col1' to be replace by 'jour', 'col2' by 'lundi', 'col3' by 'mardi', etc
<p:dataTable resizableColumns="true" liveResize="true" stripedRows="true" size="large" id="a" var="test"
value="#{testMB1.testlist}" style="padding:20px;" rows="15" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
currentPageReportTemplate="{startRecord}-{endRecord} of {totalRecords} records"
rowsPerPageTemplate="3,5,10,15,25, 50, 100, 250, 500" rowKey="#{test.id}" scrollable="true" update="mainForm:a"
frozenRows="1">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search all fields:" />
<p:inputText filterBy="#{test.id}" id="globalFilter" onkeyup="PF('test').filter()" placeholder="Enter keyword"
filterMatchMode="contains" style="width:200px;height:25px;align:right;" />
</p:outputPanel>
</f:facet>
<p:column headerText="Id" sortBy="#{test.id}">
<h:outputText value="#{test.id}" />
</p:column>
<p:column headerText="col1" sortBy="#{test.col1}" filterMatchMode="contains" filterBy="#{test.col1}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col1}" />
</p:column>
<p:column headerText="col2" sortBy="#{test.col2}" filterMatchMode="contains" filterBy="#{test.col2}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col2}" />
</p:column>
<p:column headerText="col3" sortBy="#{test.col3}" filterMatchMode="contains" filterBy="#{test.col3}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col3}" />
</p:column>
<p:column headerText="col4" sortBy="#{test.col4}" filterMatchMode="contains" filterBy="#{test.col4}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col4}" />
</p:column>
<p:column headerText="col5" sortBy="#{test.col5}" filterMatchMode="contains" filterBy="#{test.col5}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col5}" />
</p:column>
<p:column headerText="col6" sortBy="#{test.col6}" filterMatchMode="contains" filterBy="#{test.col6}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col6}" />
</p:column>
<p:column headerText="col7" sortBy="#{test.col7}" filterMatchMode="contains" filterBy="#{test.col7}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col7}" />
</p:column>
<p:column headerText="col8" sortBy="#{test.col8}" filterMatchMode="contains" filterBy="#{test.col8}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col8}" />
</p:column>
<p:column headerText="col9" sortBy="#{test.col9}" filterMatchMode="contains" filterBy="#{test.col9}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col9}" />
</p:column>
<p:column headerText="col10" sortBy="#{test.col10}" filterMatchMode="contains" filterBy="#{test.col10}"
onkeyup="PF('test').filter()">
<h:outputText value="#{test.col10}" />
</p:column>
</p:dataTable>
My dataTable
Replace all headerText with the code below (according to your mapping object). In the bean, don't forget to verify your list against null, in order not to get a NullPointerException.
<p:column headerText="#{testMB1.testlist.get(0).id}">
Technically speaking a better approach will be to create in the bean a final list, with the columns headers, and call it in the headerText.
If the headers are dynamic, you can use dynamic columns, as suggested by Jasper de Vries
I am new to primefaces. I have one datatable in my application. In that for 3 columns i need to merge some rows. That row count will be generated dynamically based on the data. If I tried to use rowspan in that particular column tag, it additionally created blank cells and the total datatable format is changed. How to do merge that datarows in primefaces. For reference, I am attaching the design and code.
Xhtml code:
<f:facet name="header">
<h:outputText value="Date"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_date}" />
</p:column>
<p:column style="font-size:12px;width:73px;" >
<f:facet name="header">
<h:outputText value="Slot"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_slot}" />
</p:column>
<p:column style="font-size:12px;width:73px;" >
<f:facet name="header">
<h:outputText value="Number of Resources Required"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_noresources}" />
</p:column>
<p:column headerText="Select" id="hSelect" style="font-size:12px;width:60px;">
<p:selectBooleanCheckbox id="Booleanchkbox" onclick="{dtstep2_tab1.select='true'}" >
<p:ajax listener="#{dtstep2_tab1.UpdateStatus}" update="panel1" />
</p:selectBooleanCheckbox>
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="Employee Name"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_empname}" />
</p:column>
<p:column style="font-size:12px;width:120px;">
<f:facet name="header">
<h:outputText value="Contact Details"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_contactdet}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="Worked Hrs to Date"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_totworkhours}" />
</p:column>
<p:column style="font-size:12px;width:50px;">
<f:facet name="header">
<h:outputText value="Agency Recruited"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_recruitmode}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="Priority"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_priority}"/>
</p:column>
<p:column style="font-size:12px;width:90px;">
<f:facet name="header">
<h:outputText value="Type of Skill"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_skilltype}" />
</p:column>
<p:column style="font-size:12px;width:120px;">
<f:facet name="header">
<h:outputText value="Restriction"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_restriction}" />
</p:column>
<p:column style="font-size:12px;width:150px;">
<f:facet name="header">
<h:outputText value="Rest. Details"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_restdet}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="B2B Days"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_b2bdays}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="B2B Hrs"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_b2bhrs}" />
</p:column>
<p:column headerText="Status" id="hStatus" style="font-size:12px;width:100px;">
<h:selectOneMenu id="cbo" value="#{step2table.rs2_status}" >
<f:selectItem itemLabel="Confirmed" itemValue="Confirmed"></f:selectItem>
<f:selectItem itemLabel="Selected" itemValue="Selected"></f:selectItem>
<f:selectItem itemLabel="Rejected" itemValue="Rejected"></f:selectItem>
</h:selectOneMenu>
</p:column>
<p:column style="font-size:12px;width:150px;">
<f:facet name="header">
<h:outputText value="Comments"></h:outputText>
</f:facet>
<h:inputText value="#{step2table.rs2_comments}" rendered="#{dtstep2_tab1.editable}"/>
</p:column>
Need to merge first three columns "date, Slot, and No of Resources Required" based on the employee column data. Guide me on this. Thanks in advance.
You can use p:summaryRow tag in p:dataTable. Example:
<h:form>
<p:dataTable var="car" value="#{dtSummaryRowView.cars}" sortBy="#{car.brand}">
<p:column headerText="Id" sortBy="#{car.id}">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year" sortBy="#{car.year}">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Brand" sortBy="#{car.brand}">
<h:outputText value="#{car.brand}" />
</p:column>
<p:column headerText="Color" sortBy="#{car.color}">
<h:outputText value="#{car.color}" />
</p:column>
<p:summaryRow>
<p:column colspan="3" style="text-align:right">
<h:outputText value="Total:" />
</p:column>
<p:column>
<h:outputText value="#{dtSummaryRowView.randomPrice}">
<f:convertNumber type="currency" currencySymbol="$" />
</h:outputText>
</p:column>
</p:summaryRow>
</p:dataTable>
</h:form>
For more information, see the primefaces showcase link: http://www.primefaces.org/showcase/ui/data/datatable/summaryRow.xhtml
This is simply not possible in the datatable.
<p:column width="440">
<p:panelGrid rendered="#{someCondition}">
<f:facet name="header">
<p:row>
<p:column width="80"><h:outputText value="#{msg.isin}" /></p:column>
<p:column width="80"><h:outputText value="#{msg.wkn}" /></p:column>
<p:column width="200"><h:outputText value="#{msg.name}" /></p:column>
<p:column width="80"><h:outputText value="#{msg.amount}" /></p:column>
</p:row>
</f:facet>
<p:row>
<p:column><h:outputText value="#{savingsPlanPosition.isin}" /></p:column>
<p:column><h:outputText value="#{savingsPlanPosition.wkn}" /></p:column>
<p:column><h:outputText value="#{savingsPlanPosition.name}" /></p:column>
<p:column><h:outputText value="#{savingsPlanPosition.amount}" /></p:column>
</p:row>
</p:panelGrid>
<p:panelGrid rendered="#{!someCondition}">
<h:link id="savingsPlanPositionDetails${rowIndex}"
title="#{msg.assign_etf}"
outcome="portfolioPositionDetail">
<f:param name="portfolioId"
value="#{savingsPlanController.portfolioId}"></f:param>
<f:param name="portfolioPositionId"
value="#{savingsPlanPosition.portfolioPositionId}"></f:param>
<f:param name="from"
value="savingsPlan"></f:param>
<h:outputText value="#{msg.assign_etf}"/>
</h:link>
</p:panelGrid>
</p:column>
I have a datatable like this. But it would not export the headers to excel :
<h:form id="formOptionList">
<p:dataTable id="OptionTable"
var="Options"
widgetVar="OptionTable"
value="#{managedBean.options}"
filteredValue="#{managedBean.filteredOptions}"
emptyMessage="No Options found."
rendered="#{managedBean.userPreferences.showTable}"
paginator="true"
rows="10"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="20,50,100"
>
<p:column id="id" headerText="ID" filterBy="id" filterMatchMode="exact" width="12%" rendered="#{managedBean.userPreferences.showID}" >
<h:outputText value="#{options.optionID}" />
</p:column>
....
....
</p:dataTable>
<h:panelGrid columns="1">
<p:panel header="Export All Data">
<h:commandLink>
<p:graphicImage value="../resources/images/menuicons/options.png" />
<p:dataExporter type="xls" target="OptionTable" fileName="Options" />
</h:commandLink>
</p:panel>
</h:panelGrid>
</h:form>
So I changed it to
<p:column id="id" filterBy="id" filterMatchMode="exact" width="12%" rendered="#{managedBean.userPreferences.showID}" >
<f:facet name="header>">
<h:outputText value="Option ID"/>
</f:facet>
<h:outputText value="#{Options.OptionID}" />
</p:column>
And I still don't see the headers in the excel file. Any ideas ?
Headers are not shown in exported excel file from primefaces datatable
Try this:
<p:column id="id" filterBy="#{Options.OptionID}" filterMatchMode="exact" width="12%" rendered="#{managedBean.userPreferences.showID}" >
<f:facet name="header>">
<h:outputText value="Option ID"/>
</f:facet>
<h:outputText value="#{Options.OptionID}" />
</p:column>
You put a <h:outputText value= ""/> after your </f:facet> ?
<p:column>
<f:facet name="header">
<h:outputText value="Your Column Name" />
</f:facet>
<h:outputText value="Your value" />
</p:column>
You can put a new column with display none, from the existing column just put an exporter false
<p:column id="id" filterBy="# Options.OptionID}"filterMatchMode="exact" width="12%" rendered="#anagedBean.userPreferences.showID}"exporter="false">
<f:facet name="header>">
<h:outputText value="Option ID" />
</f:facet>
<h:outputText value="#{Options.OptionID}" />
</p:column>
Add new column with display none and remove all sorting,filtering and rendering
<p:column exporter="true" style="display:none;">
<f:facet name="header>">
<h:outputText value="Option ID"/>
</f:facet>
<h:outputText value="#{Options.OptionID}" />
</p:column>
This works perfectly.
I want to use two f:facets: the first row one as a 'header' for the table containing only text, and the second row containing a 'global filter' (label + inputbox).
I have tried countless combinations but failed.
How can I achieve this with JSF/Primefaces?
Here is one example of what I tried:
<p:dataTable var="customer" widgetVar="customerTable" id="dataTable" value="#{customerbean.customerList}" paginator="true" rows="20" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,50,100" emptyMessage="#{text['table.customer.filter.notfound']}" filteredValue="#{customerbean.filteredCustomers}" editable="true">
<f:facet name="header">
<h:outputText value="#{text['table.customer.header']}" />
</f:facet>
<f:facet name="header2">
<h:outputText value="#{text['table.customer.filter.global']}" />
<p:inputText id="globalFilter" onkeyup="customerTable.filter()" style="width:150px" />
This is my second attempt based on the answer below:
<f:facet name="header">
<p:columnGroup type="header">
<p:row>
<p:column colspan="4">
<h:outputText value="#{text['table.customer.header']}" />
</p:column>
</p:row>
<p:separator/>
<p:row>
<p:column colspan="4">
<h:outputText value="#{text['table.customer.filter.global']}" />
<p:inputText id="globalFilter" onkeyup="customerTable.filter()" style="width:150px" />
</p:column>
</p:row>
</p:columnGroup>
</f:facet>
Whole datatable:
<p:dataTable id="customersTable" var="customer" widgetVar="customerTable" value="#{customerbean.customerList}" paginator="true" rows="20" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,50,100" emptyMessage="#{text['table.customer.filter.notfound']}" filteredValue="#{customerbean.filteredCustomers}" editable="true" draggableColumns="true" rowKey="#{customer.id}" selection="#{customerbean.selectedCustomer}" selectionMode="single">
<f:facet name="header">
<p:columnGroup type="header">
<p:row>
<p:column colspan="4">
<h:outputText value="#{text['table.customer.header']}" />
</p:column>
</p:row>
<p:separator/>
<p:row>
<p:column colspan="4">
<h:outputText value="#{text['table.customer.filter.global']}" />
<p:inputText id="globalFilter" onkeyup="customerTable.filter()" style="width:150px" />
</p:column>
</p:row>
</p:columnGroup>
</f:facet>
<p:ajax event="rowEdit" listener="#{customerbean.onEdit}" update="#this"/>
<p:column headerText="Name" sortBy="#{customer.name}" filterBy="#{customer.name}" filterMatchMode="contains">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{customer.name}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{customer.name}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="CPR" sortBy="#{customer.cpr}" filterBy="#{customer.cpr}" filterMatchMode="contains">
<h:outputText value="#{customer.cpr}" />
</p:column>
<p:column headerText="Passport No." sortBy="#{customer.passportno}" filterBy="#{customer.passportno}" filterMatchMode="contains">
<h:outputText value="#{customer.passportno}" />
</p:column>
<p:column headerText="DOB" sortBy="#{customer.dob}" filterBy="#{customer.dob}" filterMatchMode="contains">
<h:outputText value="#{customer.dob}" />
</p:column>
<p:column headerText="Options" style="width:50px">
<p:rowEditor />
</p:column>
<f:facet name="footer">
There are #{fn:length(customerbean.customerList)} customers in total.
</f:facet>
</p:dataTable>
You can't name the facet with whatever name you want. It must be something that the datatable understands. It understands "header", just like it understands "footer", but not "header2" or "footer2".
That said, you can use only one <f:facet name="header"> and inside that you can do whatever you want. You may use a <p:panelGrid columns="1">, or a <p:separator>, or even a simple table, it's just html/css formatting, like you would do anywhere in your page.
There's also a more complex way, if you want to try a little bit harder, using <p:columnGroup type="header"> and many <p:row>s inside it, for example:
<p:columnGroup type="header">
<p:row>
<p:column>
<f:facet name="header">
<h:outputText value="Your header" />
</f:facet>
</p:column>
</p:row>
<p:row>
<p:column>
<f:facet name="header">
<h:outputText value="Filter: "/>
<p:inputText value="#{filter}">
</f:facet>
</p:column>
</p:row>
</p:columnGroup>
See a full example here.
In my application I am using global filter for searching the records in Primefaces DataTable and I have applied DataExporter on the same DataTable.
When I Search any record and go for export, it return me a complete list of data instead of filtered list.
My development environment is:
java 6.0, Primefaces 3.2, JSF2.1, GlassFish Server 3.1.2, Netbeans 7.1.1
Enlisted below my dataTable and dataExporter code.
My dataTable code is::
<p:dataTable value="#{personnelController.allItems}"
emptyMessage="#{bundle.PersonnelEmpty}"
selectionMode="single"
dblClickSelect="false"
var="item"
id="tbl"
rowKey="#`enter code here`{item.id}"
sortBy="#{item.lastName}"
sortOrder="ascending"
widgetVar="itemTable"
paginator="true"
paginatorPosition="bottom"
paginatorAlwaysVisible="false"
currentPageReportTemplate="Page {currentPage} of {totalPages}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rows="10"
>
<f:facet name="header">
<p:outputPanel>
<h:outputText value="#{bundle.GlobalFilterPrompt}" />
<p:inputText id="globalFilter"
onkeyup="itemTable.filter()"
style="width:150px;"
/>
<p:watermark for="globalFilter" value="#{bundle.GlobalFilterWatermark}" />
</p:outputPanel>
</f:facet>
<p:ajax event="rowSelect" listener="#{personnelController.onRowSelectNavigate}" />
<p:column
sortBy="#{item.lastName}"
filterBy="#{item.lastName}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_lastName}"/>
</f:facet>
<h:outputText value="#{item.lastName}"/>
</p:column>
<p:column
sortBy="#{item.firstName}"
filterBy="#{item.firstName}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_firstName}"/>
</f:facet>
<h:outputText value="#{item.firstName}"/>
</p:column>
<p:column
sortBy="#{item.location.name}"
filterBy="#{item.location.name}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_locations}"/>
</f:facet>
<h:outputText value="#{item.location.name}"/>
</p:column>
<p:column
sortBy="#{item.department.name}"
filterBy="#{item.department.name}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_departments}"/>
</f:facet>
<h:outputText value="#{item.department.name}"/>
</p:column>
</p:dataTable>
I am exporting table data from outside the dataTable as::
<h:commandLink>
<p:graphicImage value="#{resource['images:excel.png']}" />
<p:dataExporter type="xls" target=":personnel:tbl" fileName="personnel" />
</h:commandLink>
Please suggest me if I am doing anything wrong.
This is my example of a usertable:
<p:dataTable id="table" value="#{myBean.users}" var="usr" rowKey="#{usr.username}" widgetVar="usrwv">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search all fields:" />
<p:inputText id="globalFilter" onkeyup="usrwv.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column headerText="Username" sortBy="#{usr.username}" filterBy="#{usr.username}">
<f:facet name="header">
Username
</f:facet>
<h:outputText value="#{usr.username}"/>
</p:column>
<p:column headerText="Role" sortBy="#{usr.role}" filterBy="#{usr.role}">
<f:facet name="header">
Role
</f:facet>
<h:outputText value="#{usr.role}"/>
</p:column>
<f:facet name="footer">
<h:commandLink>
<p:graphicImage value="/resources/images/excel.ico" title="myExcel"/>
<p:dataExporter type="csv" target="table" fileName="all_users"/>
</h:commandLink>
</f:facet>
</p:dataTable>
Also you are putting the exporter and the datatable in two different forms. Try putting them in the same form. This should work.
In the pom.xml:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10.1</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.3</version>
</dependency>
And replace:
<h:commandLink>
<p:graphicImage value="#{resource['images:excel.png']}" />
<p:dataExporter type="xls" target=":personnel:tbl" fileName="personnel" />
</h:commandLink>
<h:commandLink>
<h:graphicImage value="#{resource['images:excel.png']}" />
<p:dataExporter type="xls" target=":personnel:tbl" fileName="personnel" />
</h:commandLink>