I am using primefaces 3.2. And I need to use p:dataExporter. But parameters p:column exportable="false" and p:column exportOnly="true" does not works at all! What could be the reason of that?
Here is the code:
<p:dataExporter type="xls" target="dataTable" fileName="clients" postProcessor="#{clientBean.postProcessXLS}" />
<p:dataTable value="#{clientBean.model}" var="item" id="dataTable"
emptyMessage="#{messages['message.empty']}" styleClass="list"
paginator="true" rows="10" widgetVar="table"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
currentPageReportTemplate="(#{messages['table.page.current']}: {currentPage} #{messages['table.totalpages']} {totalPages})"
rowsPerPageTemplate="5,10,15,25,50" paginatorPosition="bottom" paginatorAlwaysVisible="false">
<p:column exportOnly="true">
<f:facet name="header">
<h:outputText value="#{clients['clientNumber']}" />
</f:facet>
<h:outputText value="#{item.clientNumber}" />
</p:column>
<p:column sortBy="#{item.clientNumber}"
exportable="false" filterStyle="display:none;">
<f:facet name="header">
<h:outputText value="#{clients['clientNumber']}" />
</f:facet>
<h:outputLink value="#{request.contextPath}/admin/management/clients/clientInfo.jsf">
<f:param name="id" value="#{item.id}" />
<h:outputText value="#{item.clientNumber}" />
</h:outputLink>
</p:column>
First exportOnly attribute doesn't exist at all in p:column tag. exportable attribute is introduced in version 3.4, so it doesn't exist in your version (3.2).
Related
I am new to prime faces and want to sort a data table using sort by and attributes but the table is not being sorted. I am using 5.3 PF.
<p:dataTable id="myTable"
styleClass="standardTable marginTopFive paddingBottom"
value="#{User.users}" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
paginatorPosition="bottom" rows="10" var="user"
emptyMessage="Error"
sortBy="#{user.userId}" sortOrder="descending">
<f:facet name="spacer">
<f:verbatim>
</f:verbatim>
</f:facet>
<f:facet name="footer">
</f:facet>
<p:column width="8%">
<f:facet name="header">
</f:facet>
<h:column>
<h:selectBooleanCheckbox
value="#{user.checked[user.userId]}" />
</h:column>
</p:column>
<p:column width="20%" sortBy="#{mpc.name}">
<f:facet name="header">
<h:outputText
value="User Name" />
</f:facet>
<h:outputText value="#{user.user_name}" />
</p:column>
<p:column width="30%" sortBy="#{mpc.email}">
<f:facet name="header">
<h:outputText
value="Email" />
</f:facet>
<h:outputText value="#{user.user_email}" />
</p:column>
</p:dataTable>
You set the name of the iterator variable as var="user", but here <p:column sortBy="#{mpc.name}"/> you called it as mpc.
So you must replace <p:column sortBy="#{mpc.name}"/> with <p:column sortBy="#{user.user_name}"/> and <p:column sortBy="#{mpc.email}"> with <p:column sortBy="#{user.user_email}">
PF 8.0 JSF 2.2: I'm using DataTable inside Tabview, I'm facing issue in DataExporter that it's exporting all tables together even when I target it using #parent..:#child(0).
<p:tabView value="#{homeMB.users}" var="user" dynamic="true" id="tbview"
cache="true" scrollable="true" style="background:transparent">
<p:ajax event="tabChange" listener="#{homeMB.onTabChange}" />
<p:tab>
<f:facet name="title">
<span style="font-size:large">#{user.userId}</span>
</f:facet>
<p:dataTable var="c"
multiViewState="true" value="#{homeMB.model}" rows="10"
rowKey="#{c.id}" lazy="true" paginator="true"
paginatorPosition="bottom" styleClass="no-border"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}"
currentPageReportTemplate="[{startRecord}-{endRecord} of {totalRecords}]"
rowsPerPageTemplate="10,20,30,40,50" rowIndexVar="inx">
<f:facet name="{Exporters}">
<div style="float: right; padding-top: 5px;">
<h:commandLink title="Export to Excel">
<p:graphicImage name="/images/excel.png" width="24" />
<p:dataExporter type="xls" target="#parent:#parent:#child(0)"
fileName="Invoice(s)" />
</h:commandLink>
</div>
</f:facet>
............
</p:tab>
</p:tabView>
Did you try setting id on table you want to export, and then setting target as id of target table. Example:
<p:datatable id="first".../>
<p:dataExporter type="xls" target="first" fileName="Invoice(s)" />
I am using primefaces 3.4.2 jar. I have a datatable with four columns. In two columns I have a datalist and I want to export text showed by datalist. But when I export it, it shows the following "org.primefaces.component.datalist.DataList#1195cc3" in the pdf and xls file.
<p:dataTable emptyMessage="#{messages['empty.result.set']}" id="searchResult" var="row" value="#{managePessoaJuridica.manageableList}" rows="10" paginator="true" paginatorPosition="top" paginatorAlwaysVisible="false" style="display:#{managePessoaJuridica.manageableList == null? 'none': ''}">
<p:column styleClass="column_icons" exportable="false">
<p:panelGrid columns="#{pessoaJuridicaController.showSelectAction?3:2}">
<p:commandButton id="selectAction" icon="ui-icon-circle-check" title="#{messages['action.select']}" action="#{pessoaJuridicaController.select(row.id)}" immediate="true" process="#this" rendered="#{pessoaJuridicaController.showSelectAction}"/>
<p:commandButton id="editAction" icon="ui-icon-pencil" title="#{messages['action.edit']}" action="#{pessoaJuridicaController.load(row.id)}" immediate="true" process="#this" update="#form"/>
<p:commandButton id="deleteAction" icon="ui-icon-trash" title="#{messages['action.delete']}" action="#{pessoaJuridicaController.delete(row.id)}" immediate="true" process="#this" update="searchResult"
onclick="return confirm('#{messages['confirm.delete.this']} #{messages['pessoa.juridica.view.title']}');" />
</p:panelGrid>
</p:column>
<p:column id="column_nome" sortBy="#{row.nome}" >
<f:facet name="header">
<h:outputText id="columnHeader_nome" value="#{messages['pessoa.nome']}"/>
</f:facet>
<h:outputText id="nome" value="#{row.nome}">
</h:outputText>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_categoriasPessoa" value="#{messages['pessoa.categorias.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="categoriasPessoa" var="item" value="#{row.categoriasPessoa}" >
<p:column>
<h:outputText id="item_categoriasPessoa" value="#{item}" converter="com.domain.configuracao.crud.CategoriaPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_identificacoesPessoa" value="#{messages['pessoa.identificacoes.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="identificacoesPessoa" var="item" value="#{row.identificacoesPessoa}">
<p:column>
<h:outputText id="item_categoriaIdentificacoes" value="#{pessoaJuridicaController.getCategoriaIdentificacao(item)}" converter="com.domain.configuracao.crud.CategoriaIdentificacaoJsfConverter"/>:
<h:outputText id="item_identificacoesPessoa" value="#{item}" converter="com.domain.configuracao.crud.IdentificacaoPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column id="column_ativo" sortBy="#{row.ativo}" >
<f:facet name="header">
<h:outputText id="columnHeader_ativo" value="#{messages['classe.base.cadastro.ativo']}" />
</f:facet>
<h:outputText id="ativo" value="#{row.ativo}" converter="com.BooleanJsfConverter" >
</h:outputText>
</p:column>
<f:facet name="footer">
<p:menuButton value="#{messages['export.action']}" rendered="#{not empty managePessoaJuridica.manageableList}">
<p:menuitem value="#{messages['export.spreadsheet']}" ajax="false">
<p:dataExporter type="xls" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.pdf']}" ajax="false">
<pe:exporter type="pdf" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.csv']}" ajax="false">
<p:dataExporter type="csv" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
</p:menuButton>
<p:spacer width="10"/>
<h:outputText value="#{fn:length(managePessoaJuridica.manageableList)} #{messages['records.found']}" rendered="#{not empty managePessoaJuridica.manageableList}"/>
</f:facet>
</p:dataTable>
But when I export it, it shows the following
"org.primefaces.component.datalist.DataList#1195cc3" in the pdf and
xls file.
Obviously, Primefaces's data exporter use the toString() method of an object to print its "value(s)".
Suggestions :
Write a custom exporter (recommended)
Override toString() method of org.primefaces.component.datalist.DataList (not advised)
It keeps showing the previous value instead of the new one.
<p:panel id="instantTransPanel" header="Quick Transfer (To Beneficiary)" toggleable="true" closable="false" toggleSpeed="500" closeSpeed="500" widgetVar="instantTransPanelVar"
rendered="#{userMBean.loggedOnUser.customer.customerType != constantuserMBean.getFETSTYPE() and (userMBean.loggedOnUser.customer.customerType != constantuserMBean.getMERCHANTTYPE() or (userMBean.loggedOnUser.customer.customerType == constantuserMBean.getMERCHANTTYPE() and userMBean.loggedOnUser.customer.hasCustomerCapability))}">
<p:commandButton value="Add New Beneficiary" onclick="addBendlg.show();" />
<br/><br/>
<p:dataTable id="beneficiariesTable" var="obj" value="#{userMBean.loggedOnUser.customer.customerBeneficiaryList}"
paginator="true" rows="20"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="20,50,100" style="width:100%" resizableColumns="true">
<p:column sortBy="#{obj.beneficiaryMsisdn}" headerText="Mobile Number" filterBy="#{obj.beneficiaryMsisdn}" filterMatchMode="contains">
<h:outputText value="#{obj.beneficiaryMsisdn}" />
</p:column>
<p:column sortBy="#{obj.beneficiaryName}" headerText="Name" filterBy="#{obj.beneficiaryName}" filterMatchMode="contains">
<h:outputText value="#{obj.beneficiaryName}" />
</p:column>
<p:column sortBy="#{obj.crt_dt}" headerText="Date Added">
<h:outputText value="#{obj.crt_dt}" />
</p:column>
<p:column headerText="Transfer">
<p:commandButton value="Transfer" update=":form:transferBenPanel" action="#{engineMBean.initTransfer(obj.beneficiaryMsisdn, obj.beneficiaryName)}" oncomplete="transferToBendlg.show();" />
</p:column>
<p:column headerText="Delete">
<p:commandButton ajax="false" onclick="return confirm('Are you sure?');" action="#{userMBean.deleteBeneficiary(obj.beneficiaryMsisdn)}" icon="ui-icon-close" style="margin:0"/>
</p:column>
</p:dataTable>
</p:panel>
After that it calls dialog and it works properly the first time but the next time I want to enter another value once clicked it pops up with the old values.
<p:dialog id="addBenDialog" header="Add Beneficiary" widgetVar="addBendlg" modal="true" dynamic="true" position="center">
<p:panelGrid columns="2" cellpadding="5" style="margin-bottom:10px;">
<f:facet name="header"></f:facet>
<h:outputLabel for="bmsisdn" value="Beneficiary Mobile Number: *" />
<p:inputText id="bmsisdn" value="#{userMBean.beneficiary.beneficiaryMsisdn}">
<p:ajax update="bname" />
</p:inputText>
<h:outputLabel for="bname" value="Beneficiary Name: " />
<h:outputText id="bname" value="#{userMBean.lookUpBeneficiaryName(userMBean.beneficiary.beneficiaryMsisdn)}" />
<f:facet name="footer">
<p:commandButton ajax="false" onclick="return confirm('Are you sure?');" action="#{userMBean.addBeneficiary}" value="Save" icon="ui-icon-disk" style="margin:0"/>
</f:facet>
</p:panelGrid>
</p:dialog>
You need to update the dialog box before it shows.
Change code as:
<p:commandButton value="Add New Beneficiary" onComplete="addBendlg.show(); update=:form:addBenDialog" />
I am using PrimeFaces 3.2 and want to export a dynamically created table as an .xls file. When i click on export, nothing seems to be happening.
Export Code
<h:commandLink id="Download_Excel_Format" ajax="false">
<p:graphicImage value="/resources/Excel_Icon.jpg" height="25" width="25" />
<p:dataExporter type="xls" target="dataTable" fileName="SomeFileName"/>
</h:commandLink>
dataTable
<p:dataTable id="dataTable" var="c" value="#{databaseSearch.customerList}"
paginator="true" rows="10" paginatorAlwaysVisible="false"
paginatorTemplate="Page {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} Rows per page {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15,30">
<p:column>
<f:facet name="header">
<h:outputText value="Machine" />
</f:facet>
<p:commandButton id="basic" value="#{c.machine}" action="#{updateEntry.setMachine(c.machine)}" oncomplete="dlg1.show();" styleClass="ui-Machinebutton" update=":Update_Entry"/>
<p:tooltip for="basic" value="Update/Delete Database Entry" showEffect="fade" hideEffect="fade" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Company" />
</f:facet>
<h:outputText value="#{c.company}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Contact" />
</f:facet>
<h:outputText value="#{c.contact}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Phone" />
</f:facet>
<h:outputText value="#{c.phone}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<!-- <h:outputText value="#{c.email}" />-->
<h:outputLink value="mailto:#{c.email}?Subject=Baseline Monitor Alert | Machine : #{c.machine}">#{c.email}</h:outputLink>
</p:column>
</p:dataTable>
Both the dataTable and the Export command are within one form, however the dataTable is in a output panel (within the form).
Form
<h:form prependId="false" id="Main_Form">
</h:form>
Output Panel
<p:outputPanel id="panel" autoUpdate="false">
</p:outputPanel>
I even updated to PrimeFaces 3.4.2 to see if the dataExporter would work, but no avail, as far as i remember 3.2 has a bug if the dataTable generates columns dynamically, but that is not the case here right? am i doing something wrong?
dataExporter option looks much simpler, but if there is an alternative which is simple enough i am up for it.
Update
I am using a GlassFish 3.1.2.2 (build 5) & NetBeans 7.2.1, i do not get any errors, just the page refresh's, has a '#' at the end of the URL and stops, no errors means that i am not lacking any dependencies either... so i am lost here ...
Ok, i found the answer ! Tricky one though ... i had a commandButton with the ID=submit...renamed it and that did the trick !
<p:commandButton id="xsubmit" icon="ui-icon-search" title="Search Database" update="panel" actionListener="#{databaseSearch.customerList}" />