Hi Jason,
Thanks for you quick reply~

Your solution works in some sense, but the problem I have the "move
node" part is control by the TreePanelListener Adapter():

            simpleNTreePanel.addListener(new TreePanelListenerAdapter
() {

                public boolean doBeforeMoveNode(Tree tree, TreeNode
node, TreeNode oldParent, TreeNode newParent, int index) {
                    //update database according to the sorting
                    return someController.moveQuestion();
                    //if success return true
            });
                public void onMoveNode(Tree simpleNTreePanel, TreeNode
node, TreeNode oldParent, TreeNode newParent, int index) {
                      GWT.log("the node is moving by
TreePanelListener  ", null);
                     //If doBeforeMoveNode() is true, this will run
and the TreeNode will be automatelly moved by TreePanelListener ;
                }
}
The only way to stop the moving (onMoveNode() ) is to return "false"
at doBeforeMoveNode().

I'm sure there is some misunderstanding in my logic, but I don't know
what it is, please guard me~

Thanks@

On Feb 27, 11:46 am, Jason Essington <[email protected]>
wrote:
> 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/threa...
>
> -jason
>
> On Feb 27, 2009, at 9:30 AM,joeyoungwrote:
>
>
>
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to