primefaces with filter between two dates show me this "javax.faces.compon ent.UIPanel@58b3 17c9" in PDF or any exports d

UI Components for JSF
Post Reply
hamzabouzidi
Posts: 4
Joined: 11 Oct 2018, 09:10

27 Sep 2019, 19:05

Hi everyone ,

i'm using :
primefaces 5.3 , wildfly 13

i have dataTable , i'm using filters in two column one for dates and one for other column . the filter for date is between two dates is work good but the problem is when i export date in pdf or xml or csv fromat all column's header show good excapte the column's date header looks like
javax.faces.component.UIPanel@58b317c9 . i find the developper who create the project and this part worked with this solution :
https://stackoverflow.com/questions/237 ... erfunction .

this is my code :

Code: Select all

<p:dataTable var="a" value="#{msg_avisMB.msg_avis_list}"
				emptyMessage="#{msg['tableVide']}" id="tblAvis" widgetVar="tblAvi"
				paginatorTemplate="{FirstPageLink} {PageLinks} {LastPageLink} {Exporters}"
				paginator="true" rows="10"
				filteredValue="#{msg_avisMB.filter_msg_avis_list}">
				<f:facet name="{Exporters}">
					<div style="float: right;">
						<h:commandLink style="margin-right:10px" process="@this">
							<p:graphicImage library="images" name="excel.png" width="24" />
							<p:dataExporter type="xls" target="tblAvis" fileName="avis" />
						</h:commandLink>
						<h:commandLink style="margin-right:10px"
							process="tblTransfertsAccountToAccount">
							<p:graphicImage library="images" name="pdf.png" width="24" />
							<p:dataExporter type="pdf" encoding="iso-8859-1" target="tblAvis"
								fileName="avis" />
						</h:commandLink>

						<h:commandLink style="margin-right:10px"
							process="tblTransfertsAccountToAccount">
							<p:graphicImage library="images" name="csv.png" width="24" />
							<p:dataExporter type="csv" encoding="iso-8859-1" target="tblAvis"
								fileName="avis" />
						</h:commandLink>
					</div>
				</f:facet>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Utilisateur" />
					</f:facet>
					<h:outputText
						value="#{a.user.civ.concat(a.user.nom).concat(' ').concat(a.user.prenom)}">
					</h:outputText>

				</p:column>
				
				<p:column headerText="date message avis" sortBy="#{a.date}"
					filterBy="#{a.date}"
					filterFunction="#{msg_avisMB.filterByDate}">
					<f:facet name="filter">
						<h:inputHidden id="filter" />
					</f:facet>
					<f:facet name="header">
						<h:outputText value="date message avis" />
						<br />
						<p:calendar id="from" pattern="dd-MM-yyyy" styleClass="filterDate">
							<p:ajax event="dateSelect"
								    onstart="$(PrimeFaces.escapeClientId('#{p:component('filter')}'))[0].value = $(PrimeFaces.escapeClientId('#{p:component('from')}_input'))[0].value + '/' + $(PrimeFaces.escapeClientId('#{p:component('to')}_input'))[0].value"
								oncomplete="PF('tblAvi').filter()" />
						</p:calendar>
						<p:calendar id="to" pattern="dd-MM-yyyy" styleClass="filterDate">
							<p:ajax event="dateSelect"
								onstart="$(PrimeFaces.escapeClientId('#{p:component('filter')}'))[0].value = $(PrimeFaces.escapeClientId('#{p:component('from')}_input'))[0].value + '/' + $(PrimeFaces.escapeClientId('#{p:component('to')}_input'))[0].value"
								oncomplete="PF('tblAvi').filter()" />
						</p:calendar>
					</f:facet>
					<h:outputText value="#{a.date}">
						<f:convertDateTime type="date" dateStyle="medium" />
					</h:outputText>
					</p:column>
					
					<p:column>
						<f:facet name="header">
							<h:outputText value="Commentaires" />
						</f:facet>
						<h:outputText value="#{a.message}">
						</h:outputText>

					</p:column>
					<p:column filterBy="#{a.niveau}" filterMatchMode="exact">
						<f:facet name="header">
							<h:outputText value="Niveau de 1 à 5" />
						</f:facet>
						<h:outputText value="#{a.niveau}">
						</h:outputText>

					</p:column>
			</p:dataTable>
focus on this part <p:calender> :

Code: Select all

<p:column headerText="date message avis" sortBy="#{a.date}"
					filterBy="#{a.date}"
					filterFunction="#{msg_avisMB.filterByDate}">
					<f:facet name="filter">
						<h:inputHidden id="filter" />
					</f:facet>
					<f:facet name="header">
						<h:outputText value="date message avis" />
						<br />
						<p:calendar id="from" pattern="dd-MM-yyyy" styleClass="filterDate">
							<p:ajax event="dateSelect"
								    onstart="$(PrimeFaces.escapeClientId('#{p:component('filter')}'))[0].value = $(PrimeFaces.escapeClientId('#{p:component('from')}_input'))[0].value + '/' + $(PrimeFaces.escapeClientId('#{p:component('to')}_input'))[0].value"
								oncomplete="PF('tblAvi').filter()" />
						</p:calendar>
						<p:calendar id="to" pattern="dd-MM-yyyy" styleClass="filterDate">
							<p:ajax event="dateSelect"
								onstart="$(PrimeFaces.escapeClientId('#{p:component('filter')}'))[0].value = $(PrimeFaces.escapeClientId('#{p:component('from')}_input'))[0].value + '/' + $(PrimeFaces.escapeClientId('#{p:component('to')}_input'))[0].value"
								oncomplete="PF('tblAvi').filter()" />
						</p:calendar>
					</f:facet>
					<h:outputText value="#{a.date}">
						<f:convertDateTime type="date" dateStyle="medium" />
					</h:outputText>
					</p:column>
when i remove the two inputs <p:calendar/> the header from date's column in pdf or csv or xsl looks good date message avis" not like befor

this is a image for my problem :
Image

please any help thank you.

hamzabouzidi
Posts: 4
Joined: 11 Oct 2018, 09:10

30 Sep 2019, 13:10

Finally i find the solution

1) is to upgrade the primefaces version to primefaces 7 and primefaces-extension 7

2) in column tag add the exportHeaderValue="your text" property

i hope my answer help someone :D
thank you .

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

30 Sep 2019, 16:10

Thanks for posting back! I was going to suggest upgrade as 5.3 is very old and many bugs have been fixed.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

hamzabouzidi
Posts: 4
Joined: 11 Oct 2018, 09:10

01 Oct 2019, 12:39

Melloware wrote:
30 Sep 2019, 16:10
Thanks for posting back! I was going to suggest upgrade as 5.3 is very old and many bugs have been fixed.
it's work good because i add exportHeaderValue but when i upgrade the version i find a lot of errors and bugs
1- datatable selection not working good and i don't know whay
2 - some comundButtons stop working
and more
exportHeaderValue doesn't existe in primefaces 5.2
if any whay to create my own custim PDF and XSL and CSV ?
i saw all the examples but nothing help and I do not understand some exaples i want stay working with the same version
because the only problem in the header in the column when i use the filter between two dates :(

NB : I'm just beginning in primefaces and jsf

thank you

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

01 Oct 2019, 13:04

PrimeFaces Extensions has an Exporter that lets you customize... Se e the example below.

https://www.primefaces.org/showcase-ext ... porter.jsf
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

hamzabouzidi
Posts: 4
Joined: 11 Oct 2018, 09:10

09 Oct 2019, 16:22

Melloware wrote:
01 Oct 2019, 13:04
PrimeFaces Extensions has an Exporter that lets you customize... Se e the example below.

https://www.primefaces.org/showcase-ext ... porter.jsf
after a lot of trys this solution work good for PDF only but not for Excel and CSV
ths solution for excel and cvs i find it here
https://github.com/rdicroce/jsfexporter

thank you for you time

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests