开发者

How to communicate between two instances of the same page in GWT

开发者 https://www.devze.com 2023-02-24 16:55 出处:网络
My GWT application needs to upload to YouTube using browser-based upload described here http://code.google.com/apis/youtube/2.0/developers_guide_java.html#Browser_based_Upload

My GWT application needs to upload to YouTube using browser-based upload described here http://code.google.com/apis/youtube/2.0/developers_guide_java.html#Browser_based_Upload I need YouTube to redirect to the same page I am uploading video from after upload is completed, so I can inform the user that the upload is done.

For this reason, I am setting the form action like this (ytPost is used to store both token and PostUrl received from YouTube).

form.setAction(ytPost.getPostUrl()+ "?nexturl="+Window.Location.getHref().toString());

From what I see in Eclipse, this happens in a thread called - Daemon Thread [Code server for fyiapp from Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729; .NET4.0C) on http://127.0.0.1:8888/FyiApp.html?gwt.codesvr=127.0.0.1:9997#tab=plan&item=69 @ _brp1HJ[BO$Y~rSZ] (Running)

The problem comes when YouTube redirects back to the same page from which I initiated the upload, but GWT instantiates a new thread called -

Daemon Thread [Code server for fyiapp from Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729; .NET4.0C) on http://127.0.0.1:8888/FyiApp.html?gwt.codesvr=127.0.0.1:9997#tab=plan&item=69 @ _brp1HJ[BO$Y~rSZ] (Suspended (breakpoint at line 104 in PostEditor))

As a result, even though I am technically on the “same page” code wise (GWT client side) from where I initiated the initial YouTube upload request, this page doesn’t have any state which I need to inform the user that YouTube upload is completed. I can issue Window.alert, or write to the status bar, but all the widgets are brand new.

The both threads continue to run from this point on.

What should I do to either be able to receive YouTube redirect on the same thread from which the upload was initiated or if this is impossible, 开发者_运维技巧how should I pass the information between two instances of the same browser page?


What about introducing an extra parameter, finished=true | false so your "setAction" would look like:

form.setAction(ytPost.getPostUrl()+ "?nexturl=" +
  Window.Location.getHref().toString()+"&finished=true");

so that the parameter "finished=true" is passed to your page when the upload is finished and it can react on it.

0

精彩评论

暂无评论...
验证码 换一张
取 消