Wednesday, February 1, 2012

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

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 view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/2FYOO_2DttUJ.
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