Missing Data in Table Export

UI Components for JSF
Post Reply
DaBe1812
Posts: 17
Joined: 11 Jun 2021, 14:32

23 Jun 2021, 15:04

Hi,

I have a page with a datatable and an exportbutton:

Code: Select all

<p:toolbar>
  <p:toolbarGroup align="right">
    <p:commandButton value="Export" icon="pi pi-upload" styleClass="ui-button-help" ajax="false">
      <p:dataExporter type="csv" target="atcSearchResults" fileName="search"/>
    </p:commandButton>
  </p:toolbarGroup>
</p:toolbar>
<p:dataTable id="atcSearchResults" var="result" value="#{searchHandler.searchResult.searchResults}"
        allowUnsorting="true" sortMode="single">
  <p:column headerText="#{searchHandler.searchResult.searchField}">
    <h:outputText value="#{result.getValue(searchHandler.searchResult.searchField)}" />
  </p:column>
  <p:column headerText="System">
    <h:outputText value="#{result.refSystem}" />
  </p:column>
  <p:columns value="#{searchHandler.searchResult.outputOrder}" var="order" headerText="#{order.header}" 
        field="getValue(order.value)" filterable="false" sortable="false"/>
</p:dataTable>
But when I export this table the columns-parts headlines are exported bit it's values stay empty.
How can I fix this?

Best regards
Daniel

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

23 Jun 2021, 17:32

Most like this value="#{searchHandler.searchResult.searchResults}" is not a stored value in ViewScoped so its lost when you go to export the values?
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

DaBe1812
Posts: 17
Joined: 11 Jun 2021, 14:32

24 Jun 2021, 08:44

Hi,

I've mad a new variable in my ViewScoped Handler where I put the results and it still isn't working.
The first column is always filled in the export an this value is also out of result.results.

I think it is an issue with the getValue in the field of the columns part.

Would it be possible to give #{searchHandler.searchResult} into a custom DataTableExporter?

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

24 Jun 2021, 13:47

I would take a step back and create a simple reoproducer using PrimeFaces Test. You can use the Showcase examples which all work for exporting then work backwards to try and figure out what is wrong with your code.
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

OliverAva
Posts: 1
Joined: 26 Jun 2021, 13:03

26 Jun 2021, 14:36

DaBe1812 wrote:
24 Jun 2021, 08:44
Hi,

I've mad a new variable in my ViewScoped Handler where I put the results and it still isn't working.
The first column is always filled in the export an this value is also out of result.results.

I think it is an issue with the getValue in the field of the columns part. workforce software monday

Would it be possible to give #{searchHandler.searchResult} into a custom DataTableExporter?
Damm even I am having a similar kind of issue, I have searched all over the internet and even have posted on number of threads on different forum, no solution seems to work. I am really frustrated, can anyone of you here help me resolve this issue, I am very much tired now.
Last edited by OliverAva on 12 Aug 2022, 21:56, edited 1 time in total.

DaBe1812
Posts: 17
Joined: 11 Jun 2021, 14:32

20 Oct 2021, 15:51

Hi,

now I've helped myself wit hanother solution:

Code: Select all

	public StreamedContent getFile() {
		file = DefaultStreamedContent.builder().name("export.csv").contentType("text/csv")
				.stream(() -> SearchResultCSVExporter.export(searchResult)).build();
		;
		return file;
	}
The exporter returns a string in csv format. Hope this helps you too.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests