Hi, ok, the next step towards universal synchronization of TreeVirtuals:
http://m53s12.vlinux.de/cboulanger/databinding/build/ Now you can create a number of trees which are connected with the store and when the store loads, all of the trees get notified of the new data and load synchroneously (looks quite neat). What is more, when you manipulate the main tree (add, prune, rename nodes), all the other trees get updated as well. So how is this done? Here is the main code again: /* * Get data from JSON-RPC backend */ var store = new qcl.databinding.event.store.JsonRpc( /* url */ "../services/index.php", /* service */ "qcl.Databinding", /* method */ null, /* marshaler */ new qcl.databinding.event.marshal.TreeVirtual ); var controller = new qcl.databinding.event.controller.TreeVirtual(null, this.treeWidget); /* * bind the store's model to the controller's model */ store.bind("model", controller, "model"); /* * bind the store's data events to the controller and * vice versa. This takes care of the synchronization */ store.bind ("dataEvent", controller, "dataEvent" ); controller.bind( "dataEvent", store, "dataEvent" ) /* * bind the server-supplied status text to the tree's status bar. * that is a very neat way of automating this and letting the server * determine the status message */ store.bind("model.statusText", this.treeWidget, "additionalStatusBarText", { converter : function( text ){ return " | " + text; } } ); [...] /* * Create a function that can recursively call itself * in order to load folder children, as long as there * are some left on the server. */ (function loadTree(data) { /* * if the function is called with boolean 'true', this * is interpreted as the start of the loading process. */ if (data === true) { cancelButton.setEnabled(true); startButton.setEnabled(false); /* * call the load method with no arguments which means that * the top level nodes are requested. */ store.load("getNodeData", [], loadTree); } /* * After the data has returned from the server, the function is * called again, and the data passed to the function. * We use a global flag to signal if the loading process should * be aborted. The data passed from the server has a 'nodes' and a * 'queue' property. The 'nodes' property will be used by the * controller to build the tree in the tree model. The 'queue' property * is an array of child ids which still have to be retrieved. If this * array is empty, we're done loading. */ else if ( ! abortJsonRpcLoad && data && typeof data == "object" && data.queue instanceof Array && data.queue.length ) { /* * now call the load method of the store with the queue of node ids that * still have to be retrieved. It will pull no more than * 10 folders (plus children) at a time to avoid timeouts. * You can play with the value of 10 to see whatever * works best, given the bandwith and server speed. When * done loading, call the loadTree function again with * the result. */ store.load("getNodeData", [ data.queue, 10 ], loadTree ); } /* * if no data, an error occurred */ else if (data === null) { tree.setAdditionalStatusBarText(" | *** An error occurred ***"); cancelButton.setEnabled(false); startButton.setEnabled(true); } /* * else, we're done. */ else { cancelButton.setEnabled(false); startButton.setEnabled(true); } })(true); If you take away the comments, there is very few code left that is necessary to do the whole magic. Next step: use the server to forward the change event to all connected clients, so you will have synchronization in different browser windows. That is actually not that difficult any more after having figured this out ;-) Enjoy, Christian -- View this message in context: http://www.nabble.com/Databinding-for-TreeVirtual-tp23528458p23545410.html Sent from the qooxdoo-devel mailing list archive at Nabble.com. ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
