Block page while export to excel

UI Components for JSF
JuanRonline
Posts: 17
Joined: 16 Jul 2014, 17:41

16 Oct 2014, 10:14

Hi, I have the next code, to export a datatable to excel:

Code: Select all

<h:commandLink>  
     <p:graphicImage name="images/excel.gif" />
     <h:outputText value="#{msg['lbl.reports.export']}" />
     <p:dataExporter type="xls" target="table" fileName="reshotel"
          postProcessor="#{reservasHotelController.postProcessXLS}" />  
</h:commandLink>
And I would like to block the page, while the export excel is generating.

Anybody can help me?

Thanks.

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

16 Oct 2014, 11:08

PF supports a block UI tag. Visit the showcase for examples of how this works.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

JuanRonline
Posts: 17
Joined: 16 Jul 2014, 17:41

16 Oct 2014, 12:07

PF doesn't works.

I need block page, and unblock it when modal window to save excel appears, something like onclick="block" onsuccess="unblock", but h:commandLink doesn't have that options, and p:dataExporter doesn't works on p:commandLink.

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

16 Oct 2014, 12:23

You can also use a modal dialog that displays a message like "Exporting, please wait" which you show when the dataExport process starts and which you hide when it finishes.
Ensure that your modal dialog cannot be closed in anyway by the user and also make sure you close it if the export process fails for any reason.
Please be aware that blocking the page will not prevent the user from pressing F5 and screwing things up.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

JuanRonline
Posts: 17
Joined: 16 Jul 2014, 17:41

16 Oct 2014, 12:41

Exactly, thats what i want, but i don't know how to get de process start event and the process finish event.

p:dataExporter doesn't has that attributes. Is there another way to emulate the onstart and oncomplete attributes?

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

16 Oct 2014, 16:10

JuanRonline wrote:Exactly, thats what i want, but i don't know how to get de process start event and the process finish event.

p:dataExporter doesn't has that attributes. Is there another way to emulate the onstart and oncomplete attributes?
Try looking at the pre- and postProcessor methods in the showcase. Use of the RequestContext to show/hide your dialog here should work.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

JuanRonline
Posts: 17
Joined: 16 Jul 2014, 17:41

23 Oct 2014, 16:15

Hi again.

It doesn't work :(

Pre and postProcess is a non-ajax process, and execute method from RequestContext just works with ajax process.

Do you know how to use execute method from a non-ajax process? Or use dataExporter like ajax process?

Thanks.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Oct 2014, 19:54

JuanRonline wrote:Hi, I have the next code, to export a datatable to excel:

Code: Select all

<h:commandLink>  
     <p:graphicImage name="images/excel.gif" />
     <h:outputText value="#{msg['lbl.reports.export']}" />
     <p:dataExporter type="xls" target="table" fileName="reshotel"
          postProcessor="#{reservasHotelController.postProcessXLS}" />  
</h:commandLink>
And I would like to block the page, while the export excel is generating.

Anybody can help me?

Thanks.
just do like many other (standard) download websites do... open a separate page (target=_blank, if that is what you desire) where download button is located, and only thing user is able to do is click download button.

why are you concerned about blocking page during a fileDownload? do you see many other websites out there that block page during a fileDownload?
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

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

23 Oct 2014, 20:16

Read the topic Howard, an excel download is generated, so that can take a while and you do not want the user to press the button twice or more when being impatient

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Oct 2014, 20:43

kukeltje wrote:Read the topic Howard, an excel download is generated, so that can take a while and you do not want the user to press the button twice or more when being impatient
hmmm...
JuanRonline wrote:Hi, I have the next code, to export a datatable to excel:

Code: Select all

     <p:dataExporter type="xls" target="table" fileName="reshotel"
          postProcessor="#{reservasHotelController.postProcessXLS}" />  
And I would like to block the page, while the export excel is generating.
Ronald, I read the OP. Did OP say block the 'button' or 'page'? why would OP want to block the 'page'? Hmmm, target="table". Must be a datatable with multiple Excel buttons to click?

Why block a 'page' when/while one Excel report being generated? Excel report takes minutes (or many seconds) to generate?

Hmmm, when I go to Maven Central download website, is there a block-page, or I can download multiple files at a time? blocking a 'page' or even blocking a 'download' (or 'excel') button is abnormal on web pages/site that offer files to download.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 42 guests