Something like this (not tested) @Inject private ComponentResources resources;
@Inject private JavaScriptSupport jss; @Persist(PersistanceConstants.FLASH) private String pdfUrl; @SetupRender void setupRender() { if (pdfUrl != null) { jss.addScript("document.location.href = '%s';", pdfUrl); } } void onSuccessFromForm() { long pdfId = doWorkPriorToPdfGeneration(...); pdfUrl = resources.createEventLink("generatePdf", pdfId); } StreamResponse generatePdf(long pdfId) { // generate the PDF } If you don't want to use flash persistence, you can use page activation context or a request parameter etc. On 24 April 2013 17:51, George Christman <gchrist...@cardaddy.com> wrote: > Hi Lance, I think I'm with you most of the way with the exception of > generating a link to the pdf event. > > So I'm returning PurchaseRequest.class in my onSuccess method which would > for the page to reload with context from onPassivate, this should resolve > my sync issues. Where I'm lost is how to trigger the script to call the > StreamResponse. I thought maybe this could be done in the url like so, > http://domain/purchaserequest/958:generatepdf. I'm just not sure what the > appropriate way of doing this is, or how to do it at that. I'm assuming you > would need some sort of business logic to prevent people from just using > that same URL over and over again. How would you tigger the script on > return? > > Thanks Lance. > > > On Wed, Apr 24, 2013 at 12:37 PM, Lance Java <lance.j...@googlemail.com > >wrote: > > > Split it into 2 phases: > > > > Phase 1: Submit form > > Do the work (webservice + version increment) > > Generate a link to the generatePDF event > > Return the page to be re-rendered > > > > Phase 2: Re-render the page > > Use javascript to download the PDF once the page has loaded. > > >