private void doMove(/*required params*/){
// node move Implementation
}
public void moveQuestion(TreeNode node, TreeNode oldParent, TreeNode
newParent, int index){
// setup
// call rpc
service.resorting(/*params*/, new AsyncCallback<Boolean>(){
public void onSuccess(Boolean result){
if (result) doMove(/*params*/);
else /* whine loudly */;
}
onFailure(Throwable caught){
// whine here too
}
});
// do nothing after the call as doMove will be called onSuccess
}
also, read this:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/faca1575f306ba0f/3be719c021aa19bd
-jason
On Feb 27, 2009, at 9:30 AM, joe young wrote:
>
> I'm trying to resort my nodes of the tree and save the new sorting
> into the database. I want to make sure the save is successful before
> I move the node, o/w it will display alert.
> public boolean doBeforeMoveNode(Tree tree, TreeNode
> node, TreeNode oldParent, TreeNode newParent, int index) {
> return simpleNTreePanel.moveQuestion
> (node,oldParent,newParent,index);
> }
>
> In moveQuesiton(), i called RPC and it will return a Boolean so me
> that if it is successful or not.
>
> public boolean moveQuestion(TreeNode node, TreeNode oldParent,
> TreeNode newParent, int index) {
> service.resorting(theNode.getId(), "1", new AsyncCallback() {
>
> public void onSuccess(Object result) {
> Boolean result = (Boolean) result;
> <!-- If result is true
> moveQusetion() will return true and node will be moved;
> otherwise
> Window.alert("ERROR Moving failed");
> and return false and it stop the node moving
> -->
> }
>
> public void onFailure(Throwable caught) {
> Window.alert("ERROR Moving failed");
> }
> });
> }
>
> How can moveQuestion() wait until the RPC return the result?? I don't
> want to use wait() coz it might took forever or it only take in sec.
>
> Sorry for the stupid question.
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---