- Can't you rather link to a servlet (passing the jsonDTO data in the URL) that would do the equivalent of your "performRPC" method followed by the "computation based on the result and create the url thereby" and issue a redirect?
- Alternatively, how about replacing the Anchor with a button and passing the generated URL to Window.open(), or then only using an Anchor (e.g. if the goal is to download a generated file)
The problem with using an Anchor whose href is not yet known is that you get in the way of the user: what should happen when you Shift+click to download? Ctrl+click to open in a new tab/window? Right-click to do any of the previous action, or bookmark the URL, or copy it to the clipboard, etc.
On Tuesday, February 5, 2013 12:54:04 PM UTC+1, membersound wrote:
Hi,
I have an Anchor that onClick performs an RPC call to a servlet. Based on the outcome I want to set the hRef of the Anchor, and then perform the open url action of the Anchor.
BUT: how can I tell the anchor to wait for the Callback to finish before trying to open the url?
@UiField
Anchor anchor;
@UiHandler("anchor")
void onClick(ClickEvent evt) {
MyService.performRPC(jsonDTO, new MessageCallBack());
//delay here until callback finised and has set the hRef of anchor
}
class MessageCallBack implements AsyncCallback<String> {
@Override
public void onSuccess(String result) {
// do some computations based on the result and create the url thereby
String url =...
anchor.setHref(url);
}
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment