Thanks~ it works perfectly. But if i want to use gwt.ext's MessageBox, so that I can have the same look and feel, how do it do it? It is like having a confirm box listener waiting for result, and meanwhile doBeforeMoveNode() is waiting for the result from the listener.
On Jan 28, 1:50 pm, Ian Petersen <[email protected]> wrote: > I haven't used confirmation dialogs in GWT before--I've only used them > in straight Javascript--so take the following with a grain of salt. > > > > On Wed, Jan 28, 2009 at 10:29 AM, joe young <[email protected]> wrote: > > I do the following: > > > public boolean doBeforeMoveNode(Tree tree, TreeNode node, TreeNode > > oldParent, TreeNode newParent, int index) { > > GWT.log("treePanel.onMoveNode", null); > > if (oldParent.getId().equals(newParent.getId())) { > > return false; > > } > > MessageBox.confirm("Confirm", "You are about to > > move this node and its child nodes. Would you like to save your > > changes to database?", > > new MessageBox.ConfirmCallback() { > > > public void execute(String btnID) { > > if (btnID.equals("yes")) { > > return true; > > } > > } > > }); > > } > > > public void onMoveNode(Tree treePanel, TreeNode node, > > TreeNode oldParent, TreeNode newParent, int index) { > > GWT.log("treePanel.onMoveNode", null); > > controller.moveNode(treePanel, node, oldParent, > > newParent); > > } > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > but clearly the error occur at > > public void execute(String btnID) { > > if (btnID.equals("yes")) { > > return true; > > } > > } > > since i cannot return true. > > > So how do i return true in doBeforeMoveNode() when I need to wait till > > MessageBox return the result (Yes)?? > > You're greatly confusing matters. Just use Window.confirm(): > > public boolean doBeforeMoveNode(Tree tree, TreeNode node, TreeNode > oldParent, TreeNode newParent, int index) { > GWT.log("treePanel.onMoveNode", null); > > if (oldParent.getId().equals(newParent.getId())) { > return false; > } > > return Window.confirm("You are about to move this node and its child > nodes. Press OK to save your changes to the database, or Cancel to > lose your changes."); > > } > > See the Window.confirm() doc > here:http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/g...) > > Ian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
