May the same UICommand component prepare dataExporter's data source and trigger the dataExporter to get the XLS file?

UI Components for JSF
Post Reply
rosière
Posts: 92
Joined: 28 Nov 2012, 15:55
Contact:

18 Sep 2018, 12:48

Hello,
I would like my command link to achieve 2 goals after one click:
1. call a backing bean method in action attribute to fill the list of data to dump.
2. trigger data Exporter to download the data file.

Howeve this seems impossible.
I also tried to trigger programmatically with JQuery a commandButton that encapsulates data Exporter.
but it never went into effect.

So is my presumption reasonable? Thanks

Code: Select all

                   <p:dataTable id="myList" value="#{myBean.list}" >
....
 <p:commandLink action="#{myBean.fillList}"
                                           update="myPanel" oncomplete="$(button[id*='exporterLink']).submit();" />
                            <p:commandButton id="exporterLink" ajax="false" rendered="#{service.showExportLink}" oncomplete="alert('We will now trigger exporter...');"
                                             widgetVar="exporterLink" styleClass="NoDisplay">
                                <p:dataExporter type="xls" target="myList" fileName="detailedServices" />  
                            </p:commandButton>

JDK: 1.8
Operating system: Windows 10
server: 4.1.1.171 #badassfish (build 136)
IDE: NetBeans 11.2
primefaces : version 6.0
primefaces extensions : 4.0.0
Apache Poi: 3.15

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 Sep 2018, 13:41

I don't see any reason why it should not work from the oncomplete. Just make sure you have the right selector and do a 'click()' instead of submit(),

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 59 guests