3 Replies Latest reply on Sep 28, 2006 9:39 AM by dimival

    Cairngorm / Tree Control

    blackshirt
      I'm using the Cairngorm framework to dynamically add nodes to my tree. I use a custom object I created that has public properties: nodeid, nodename, and children.

      Everything works fine when dynamically adding nodes in the "execute" function of my Command class. The issue comes in where I make dynamic call to the server and the results come back into the "result" function of my Command class. While debugging I noticed that the parent node on the treeview must of fired its expand event because the "Open" icon was shown. Once I added the new children they did not up under the parent. I tried to call force an expand call again like this
      trData.expandItem(_treeNodeVO,_expand,false,true,null);
      but that still didnt work. Once I closed the main parent node and clicked on it again the children nodes "did" show.

      So I have concluded that somewhere between the "execute" function and server call the node expand event is fired before the "result" function. My main question is what can I do so the children will be seen? force and event to be fired? Call a method off the tree itself? etc....

      Thanks
        • 1. Re: Cairngorm / Tree Control
          dimival Level 1
          Remote calls to the server are asynchronous so you can't be sure of when the result will arrive. The best thing is to register an EventListener for the resultEvent and then add the children. If an event is firing before time, you can register a listener for this event and then stop its propagation, like this:

          myTree.addEventListener( event, accHandler, true ); // true means to use capture phase

          private function accHandler( event ) : void
          {
          some condition ( ) {
          event.stopImmediatePropagation();
          }
          }

          You will need a condition to decide when to stop the propagation of the event and when not
          • 2. Re: Cairngorm / Tree Control
            blackshirt Level 1
            Thanks for the reply.

            I'm confused on the addEventListener. I am actually using a custom RemoteObject tag to call my service. Similiar to OpenAMF call using PHP. In that object it registers the "result" function as my event listener. This is just wrapped by a cairngorm command class. So I'm not sure if I understand what to do. Can you clarify how to do this with the cairngorm framework?

            I appreciate the feedback.

            thanks
            • 3. Re: Cairngorm / Tree Control
              dimival Level 1
              My question here will be: why are you using Cairngorm? is your application THAT big? Cairngorm should be used when your application is kinda big and will require many calls to diferent java methods.

              The problem with Cairngorm is that the result is handled by the Command class and from there you need your application (which issued the java call) to recover control, this is, you need somehow to send the result to your application, your Tree in the example.

              I think i would need to see a snippet of your code to get a clearer idea, but my recomendation would be not to use Cairngorm unless your application is big and complex, otherwise you can use a normal remote call.