You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Federico Fanton <ff...@ibc.it> on 2007/10/11 17:00:46 UTC

Page expired upon file download + model update

Hi everyone!
I have a form with some fields and a submit button which says "Save and print".
The button has setDefaultFormProcessing(false), and overrides onSubmit so that the form model object is sent to the persistence layer and printed immediately afterwards. The persistence layer *may* alter the object, so I have to reload it. My problem is that this reloading causes a "page expired" when I press the button for a second time.

My onSubmit:

if(getForm().process()){
   MyBean data=getForm().getModelObject();

   data=Persistence.save(data);

   // Create PDF and send it to the browser
   IResourceStream s = new ByteArrayResource("application/pdf", buildPDF(data)).getResourceStream();
   RequestCycle.get().setRequestTarget( new ResourceStreamRequestTarget(s) );

   getForm().setModelObject(data);
}

I think the page expires because sending the PDF to the browser "blocks" the request cycle, so the browser never renders the new version of the page.. Is there a way to do this? Am I doing Something Wrong? ^__^;
Many thanks for your time!


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Page expired upon file download + model update

Posted by Federico Fanton <ff...@ibc.it>.
On Mon, 15 Oct 2007 09:37:50 +0200
Federico Fanton <ff...@ibc.it> wrote:

> > See here 
> > http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-Startingdownloadafterformsubmission(Wicket1.1)

Sorry, I forgot to say I'm using 1.3-beta3


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Page expired upon file download + model update

Posted by Federico Fanton <ff...@ibc.it>.
On Fri, 12 Oct 2007 17:59:11 +0400
Andrew Klochkov <a....@webalta-team.com> wrote:

> See here 
> http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-Startingdownloadafterformsubmission(Wicket1.1)

Thanks for your answer!
Following the example I tried writing to WebResponse and setting ResponsePage to null, but the behavior is still the same.. That is, when I press the "print" button a second time, I get the "page expired" error. I think I need to send the download AND refresh the page, but maybe it's not possible at all?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Page expired upon file download + model update

Posted by Andrew Klochkov <a....@webalta-team.com>.
See here 
http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-Startingdownloadafterformsubmission(Wicket1.1)

Federico Fanton wrote:
> Hi everyone!
> I have a form with some fields and a submit button which says "Save and print".
> The button has setDefaultFormProcessing(false), and overrides onSubmit so that the form model object is sent to the persistence layer and printed immediately afterwards. The persistence layer *may* alter the object, so I have to reload it. My problem is that this reloading causes a "page expired" when I press the button for a second time.
>
> My onSubmit:
>
> if(getForm().process()){
>    MyBean data=getForm().getModelObject();
>
>    data=Persistence.save(data);
>
>    // Create PDF and send it to the browser
>    IResourceStream s = new ByteArrayResource("application/pdf", buildPDF(data)).getResourceStream();
>    RequestCycle.get().setRequestTarget( new ResourceStreamRequestTarget(s) );
>
>    getForm().setModelObject(data);
> }
>
> I think the page expires because sending the PDF to the browser "blocks" the request cycle, so the browser never renders the new version of the page.. Is there a way to do this? Am I doing Something Wrong? ^__^;
> Many thanks for your time!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>   


-- 
Andrew Klochkov


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Page expired upon file download + model update

Posted by Federico Fanton <ff...@ibc.it>.
On Thu, 11 Oct 2007 17:00:46 +0200
Federico Fanton <ff...@ibc.it> wrote:

> The button has setDefaultFormProcessing(false), and overrides onSubmit so that the form model object is sent to the persistence layer and printed immediately afterwards. The persistence layer *may* alter the object, so I have to reload it. My problem is that this reloading causes a "page expired" when I press the button for a second time.

Ouch! Looks like it was simply a serialization issue.. ^^; Is there a way to trigger "blocking" Serialization exceptions instead of simply logging them?
Many thanks :)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org