This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 11, 2013, 9:51 PM
13 Posts
topic has been resolvedResolved

XAgent Concept -Excel Generation using Apache POI

  • Category: Other
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: XAgent
  • Replies: 5
Hi,

XAgent Concept :
There will be 2 xpages, one for the display(Generate Report is placed on this Xpage) and the other xpage is set to be hidden with rendered= false. IN the 2nd Xpage, "BeforeRenderResponse" event we can call Apache POI to generate Excel.
  
I am using Apache POI for generating Excel reports. Link that generates Excel works fine only once, if I use the "Full Update " for the "Onclick" event.
After the first time, If I click on the link to generate Excel , it won't do anything. The page is submitted to the server, but it won't load the whole page back correctly.
I have to refresh the whole page for the link to work again.
 
To avoid this,I want to use "No Submission"   for the link and call the xpage which generates the Excel. Here I am facing a challenge to pass the parameters to the intermediate Xpage. I am passing the field1 value through the parameter, but it comes as NULL.

What is the best way to pass the parameters from the display Xpage to the intermediate xpage? 

  <xp:link escape="true" text="Generate Report"
                            id="link1"
                            value="/xpPOI.xsp">
                            <xp:this.parameters>
                                <xp:parameter name="String1">
                                    <xp:this.value><![CDATA[#{javascript:getComponent("fld1").getValue();

}]]></xp:this.value>
                                </xp:parameter>
                            
                            </xp:this.parameters>
 </xp:link>

Please advise


Thanks in Advance  
Apr 11, 2013, 10:29 PM
366 Posts
Re: XAgent Concept -Excel Generation using Apache POI
 You need to store the "parameters" to a session scoped variable and then read those values from the intermediate XPage.


As far as the button not working a second time add the following code to the link/buttons CLIENT SIDE event 


   setTimeout(function() { XSP.allowSubmit() }, 1000);


then you can submit multiple times. 


FYI, if you do a full refresh from the button then you don't need the intermediate XPage (XAGENT) as you can simply put all of the ssjs code in the link event 
Apr 11, 2013, 11:09 PM
586 Posts
Re: XAgent Concept -Excel Generation using Apache POI
 Paul - 


What does this code mean / do? 


As far as the button not working a second time add the following code to the link/buttons CLIENT SIDE event 


   setTimeout(function() { XSP.allowSubmit() }, 1000);


then you can submit multiple times. 


Is that a common solution to some behavior or specific to exporting to Excel?


Thanks! 
Apr 12, 2013, 2:45 PM
366 Posts
Re: XAgent Concept -Excel Generation using Apache POI
 I'm not sure what the "default" timeout is, but it allows for being abile to click a submit button multiple times without having to refresh the page.


Doesn't have anything to do with the apache poi at all, more the workflow of calling an XAgent from a submit button. 
Apr 12, 2013, 3:43 PM
13 Posts
Re: XAgent Concept -Excel Generation using Apache POI
 
Excellent Paul.
 This XSP.allowsubmit() works fine... I was curious to check what this line does and researched a bit on this method. Found something which might be helpful to others.
-----------------------
legacy Client Side JavaScript
code or libraries your application uses might be performing page submission using
The Public XSP Client Side JavaScript Object Functions
document.forms[0].submit() or the like. Therefore, consider revising this
code to avoid page submission, instead favoring XPages’ own features or alternatively
modifying such code to use the XSP.canSubmit(), XSP.allowSubmit(), and XSP.
validateAll() functions to provide a more robust page submission behavior.
If the page is not submitted after a call to XSP.canSubmit(), this function should be
called to reenable the page submission mechanism

--------------------------- 
 
Thanks very much Paul. This forum is awesome!

  
 
Jan 18, 2016, 6:54 PM
7 Posts
Re: XAgent Concept -Excel Generation using Apache POI

Paul,

 

Thanks for your reply to this question!  I just found this post, via Google, I have been looking for this solution for a couple years now, I knew someone had to know how to beat this "download--only-once" monster I have been facing.

 

We have a print as pdf link on several xpages, and once you printed to pdf, the page was dead for several minutes (unless you reloaded the page). This XSP.allowSubmit() seems to have solved the issue. We can print a pdf, change parameters and immediately print a new pdf.

 

Today is a good day.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal