DataExporter issue with selectionOnly="true"

UI Components for JSF
sivaprasadreddy.k
Posts: 21
Joined: 31 Jan 2012, 11:46

03 Jul 2013, 12:23

Hi,
I have a PrimeFaces DataTable and I want to use DataExporter to export only selected rows.

Code: Select all

<p:dataTable id="usersTbl" var="user" value="#{adminController.users}" 
		rowKey="#{user.id}"  paginator="true" rows="10"
		selectionMode="multiple" selection="#{adminController.selectedUsers}" >  
	 <p:column>  
		<f:facet name="header">  
			<h:outputText value="Email" />  
		</f:facet>
		<h:outputText value="#{user.emailId}" />  
	</p:column>
</p:dataTable>

Code: Select all

<h:commandLink>  
	<p:graphicImage value="/resources/images/excel.png"/>
	<p:dataExporter type="xls" target="usersTbl" fileName="users" selectionOnly="true" />
</h:commandLink>
<h:commandLink>  
	<p:graphicImage value="/resources/images/pdf.png"/>
	<p:dataExporter type="pdf" target="usersTbl" fileName="users" selectionOnly="true"/>
</h:commandLink>
<h:commandLink>  
	<p:graphicImage value="/resources/images/csv.png"/>
	<p:dataExporter type="csv" target="usersTbl" fileName="users" selectionOnly="true"/>
</h:commandLink>
<h:commandLink>  
	<p:graphicImage value="/resources/images/xml.png"/>
	<p:dataExporter type="xml" target="usersTbl" fileName="users" selectionOnly="true"/>
</h:commandLink>
With this I am facing few issues:

1)If selectedUsers is of type List<User>, when I click on Export (XLS/PDF/CSV/XML) I am getting NumberFormatException for input string "id".

2)If I change the selectedUsers variable type to User[] then Export to XML and PDF are working fine.
But for CSV I am getting all the selected rows data in a single row.
For XML I am getting all the selected rows data in a single <usersTbl> tag instead of separate <user> tag wrapped for each user row.

Any work around for this?
PrimeFaces 3.5 | Mojarra 2.1.13 (JSF 2.1)
Tomcat 7 | JDK1.6
Windows 7 | Mozilla FF,Chrome&IE

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

03 Jul 2013, 12:54

It should work with both list and array type.selectionOnly implmentation is similar to all types of export.Most of the time users will use list instead array type so there is a less chance to find the issue.However I will check it once (when I get time free time) and let you know.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

sivaprasadreddy.k
Posts: 21
Joined: 31 Jan 2012, 11:46

03 Jul 2013, 16:21

Thanks Sudheer.

Also it seems preProcessor and postProcessor work for XLS and PDF, but not for CSV/XML. I have looked into Exporter implementations and preProcessor and postProcessor are not used for CSV and XML Exporters at all.
PrimeFaces 3.5 | Mojarra 2.1.13 (JSF 2.1)
Tomcat 7 | JDK1.6
Windows 7 | Mozilla FF,Chrome&IE

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

03 Jul 2013, 16:27

sivaprasadreddy.k wrote:Also it seems preProcessor and postProcessor work for XLS and PDF, but not for CSV/XML. I have looked into Exporter implementations and preProcessor and postProcessor are not used for CSV and XML Exporters at all.
Are you talking about primefaces dataexport or primefaces extensions exporter component?At present Extensions exporter implemented for PDF and Excel types,it will be implemented for CSV/XML later.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

sivaprasadreddy.k
Posts: 21
Joined: 31 Jan 2012, 11:46

03 Jul 2013, 17:05

I am talking about PrimeFaces dataExporter(<p:dataExporter) only.
PrimeFaces 3.5 | Mojarra 2.1.13 (JSF 2.1)
Tomcat 7 | JDK1.6
Windows 7 | Mozilla FF,Chrome&IE

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

03 Jul 2013, 18:53

Yes,PreProcessor and postProcessor supported only for PDF and Excel export types but not for XML and CSV types.In PDF and XL export we can pass the document object to customize but it is not possible with other two types.It will use outputstreams.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

sivaprasadreddy.k
Posts: 21
Joined: 31 Jan 2012, 11:46

04 Jul 2013, 04:06

Thanks Sudheer.

Did you get a chance to look at List vs Array issue for selectionOnly="true"?
PrimeFaces 3.5 | Mojarra 2.1.13 (JSF 2.1)
Tomcat 7 | JDK1.6
Windows 7 | Mozilla FF,Chrome&IE

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

04 Jul 2013, 04:44

You are welcome.sorry I didn't get the time to check this issue.I will let you know once I have look into that issue.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

16 Jul 2013, 23:20

sivaprasadreddy.k wrote:With this I am facing few issues:

1)If selectedUsers is of type List<User>, when I click on Export (XLS/PDF/CSV/XML) I am getting NumberFormatException for input string "id".

2)If I change the selectedUsers variable type to User[] then Export to XML and PDF are working fine.
But for CSV I am getting all the selected rows data in a single row.
For XML I am getting all the selected rows data in a single <usersTbl> tag instead of separate <user> tag wrapped for each user row.
Hi Siva,

Sorry for the late reply.Both issues can be replicated and valid issues

1.AFAIK, Datatable multiple selection(aka multiple selection property) only supports array type but not list yet.As I remember it needs to be fixed in 3.4.x or 3.5.x Elite releases but I'am not sure whether it is fixed or still in pending status.Optimus/Thomas can confirm on this.
2.CSV and XML issues need to be resolved from exportSelectionOnly method.I will provide a patch soon or Create an issue in the issue tracker.

Thanks for your finding :)
Last edited by sudheer on 29 Aug 2013, 15:27, edited 1 time in total.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

17 Jul 2013, 08:18

Issue 1 is fixed in PF 3.4.3 Elite release http://blog.primefaces.org/?p=2523.By mistake Optimus added the target version for 3.5 as well.It won't work with 3.5 release as of now.

Fixed Issue from issue tracker https://code.google.com/p/primefaces/is ... il?id=4804 .I will make try on it today.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests