I wish to embed an asynchronous call to the server inside a method
that MUST NOT return until the server has responded. So I am looking
for a way to achieve a non-busy wait in GWT. I thought I could use a
modal popup dialog to stop the next line from being executed until the
dialog is closed  and only after the response from server arrives.
Unfortunately the GWT modal dialog does not do what I thought it would
do -- which is block everything and wait at the line where the
PopupPanel.show() method is called. See method below

<code>
public boolean doPost(String url, String postData) {
        RequestBuilder builder = new
RequestBuilder(RequestBuilder.POST, url);
        final int STATUS_CODE_OK = 200;
        final PopupPanel dlg = new PopupPanel();
        dlg.setModal(true);
        dlg.setGlassEnabled(true);
        try {
            builder.setHeader("Content-Type", "application/x-www-form-
urlencoded");
            builder.sendRequest(postData, new RequestCallback() {
                public void onError(Request request, Throwable
exception) {
                   dlg.hide();
                }

                public void onResponseReceived(Request request,
Response response) {
                    int li_status = response.getStatusCode();
                    if (li_status == STATUS_CODE_OK) {
                        //bravo
                    }
                    dlg.hide();
                }
            });
            builder.setTimeoutMillis(3000);
            dlg.show();
            return true;
        } catch (RequestException e) {
            GWT.log(e.getLocalizedMessage());
        }
        return false;
    }
</code>

I want the line

<code>
return true;
</code>

to be executed only after the dialog is closed just like what would
happen if I used Window.confirm to achieve the modality as shown
below.

<code>
   Window.confirm("yes or no");
    return true;
</code>


Any ideas on how I can achieve this.


Thanks,

Melody

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to