Wednesday, February 1, 2012

Re: How to stall GWT app while it is writing file in background? Timer object??

Hi Mark,

Your suggestion worked perfectly, except for one small thing.  For some reason moving the Window.open from the button click event, to the onSuccess method, now creates a "pop up" window, instead of a new tab..  Its weird because they are both being executed within the presenter class so i'm unsure why its doing that.  Also since its now making a popup instead of a new tab, google chrome setting need to be changed to allow popups.  Do you know why moving window.open would all of a sudden make a pop up instead of a new tab?

Thanks,

Joshua

On Wed, Feb 1, 2012 at 1:41 PM, Mark <mdsholund@gmail.com> wrote:
The whole idea between AJAX is asynchronous operation, the client
continues working while the server does work.  There's no telling how
long the server will take to do its work so a Timer is not the best
option.  Since you want the client to react when the server finishes
you need to pass the workload to the server method and pass an
AsyncCallback object.  In that object you put your Window.open() call
in the onSuccess() method.

Hope this helps.

On Feb 1, 1:52 pm, Joshua Carey <jc11...@gmail.com> wrote:
> I have a gwt application that calls a gwt servlet (from my presenter class)
> to write a PDF file to disk, then in my presenter class I display the newly
> created PDF using Window.open("my.pdf");.  The problem is that the
> window.open executes before the pdf is finished writing to disk.  I would
> like to know if there is a way to stall any further statements from
> occurring until the pdf is finished writing.  Or is there a way to use some
> sort of timer object that waits 5 seconds or more while the PDF is  being
> created?  It would be nice to prompt the user a message box that says
> "please wait while PDF is retrieved" and then when the PDF is finished
> writing, we could automatically close the message box and execute the
> window.open("my.pdf") command.  Here is the lines of code in the presenter
> class:
>
> ButtonCell genericButtonCellType = new ButtonCell();
> FieldUpdater<EOMDocument, String> previewUpdater = new
> FieldUpdater<EOMDocument, String>()
> {
> @Override
> public void update(int index, EOMDocument object, String value)
> {
> if (object.getByteBlob() == null) {
> Window.alert("Sorry but the PDF you are requesting from the database is
> empty. Please select another PDF to view!");} else {
>
> eventBus.writePdf(object.getByteBlob(), object.getIdocNumber());
>         String blobURL =  GWT.getHostPageBaseURL() + "sp_pdf/" +
> object.getPreviewBlobPath();
>         Window.open(blobURL, "Search And Preview - PDF Review", null);
>
> }
> }
> };
>
> Thanks for the help.
>
> Joshua

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment