Wait/Block for user input

71 views
Skip to first unread message

blambeau

unread,
Jul 22, 2006, 2:07:13 PM7/22/06
to Google Web Toolkit
Hi !

The GWT documentation clearly states that java thread utiilties may not
be used because javascript does not support threads.

However, does anyone knows a way to block a method execution for user
input ? More precisely, I'm currenly trying to do something like this :

/**
* opens a user dialog and returns the entered value
*/
public String showInputDialog(String message) {

d = ... // open a DialogBox

// WAIT FOR DIALOG CLOSE
// something like wait() in java
// ... and without 'while (true) like' stuff

// return entered value (for example)
return d.getValue();
}

Is there a GWT or javascript solution to do that ? or is it actually
impossible due to javascript restrictions ?

A solution should be to implement some continuation pattern (like
GWT/RPC for example) ... but I would like to avoid this if possible.

Thx
blambeau

Paul Strack

unread,
Jul 22, 2006, 4:14:52 PM7/22/06
to Google Web Toolkit
Use event-driven programming. Register an appropriate event listener to
determine when the dialog is closed, and execute the appropriate code:

public String showInputDialog(String message) {

d = ... // open a DialogBox

d.addPopupListener(new PopupListener() {
public void onPopupClosed(PopupPanel sender, boolean
autoClosed) {
// Your code here ...
}
});
}

Reply all
Reply to author
Forward
0 new messages