jin1212
28 Jun 2007, 2:04 PM
Hello,
I've been using prototype/scriptaculous with J2EE on the server side for a while now. Today I just discovered ext's treepanel, which is what I really need for my current project.
I included ext-prototype-adapter.js, ext-all.js, scriptaculous.js on my page
I tried to follow the example from demo:
function enableTree(){
var Tree = Ext.tree;
var tree = new Tree.TreePanel('tree-div', {
animate:true,
loader: new Tree.TreeLoader({dataUrl:'servlet?action=GetJsonTree'}),
enableDD:true,
containerScroll: true
});
tree.loader.on('load', function(){alert("load")}, this,true);
tree.loader.on('loadexception', function(){alert("load exception")}, this,true);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Ext JS',
draggable:false,
id:'source'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
}
From my servlet I write out this JSON string:
[{"text":"widgets","id":"source\/widgets", "leave":false}]
On the client side, I see the load, and loadexception alert, and I can only see Ext js as root and nothing else. I appreciated if I can get some guidance, as I am brand new to ext and JSON.
thank you, jin
I've been using prototype/scriptaculous with J2EE on the server side for a while now. Today I just discovered ext's treepanel, which is what I really need for my current project.
I included ext-prototype-adapter.js, ext-all.js, scriptaculous.js on my page
I tried to follow the example from demo:
function enableTree(){
var Tree = Ext.tree;
var tree = new Tree.TreePanel('tree-div', {
animate:true,
loader: new Tree.TreeLoader({dataUrl:'servlet?action=GetJsonTree'}),
enableDD:true,
containerScroll: true
});
tree.loader.on('load', function(){alert("load")}, this,true);
tree.loader.on('loadexception', function(){alert("load exception")}, this,true);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Ext JS',
draggable:false,
id:'source'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
}
From my servlet I write out this JSON string:
[{"text":"widgets","id":"source\/widgets", "leave":false}]
On the client side, I see the load, and loadexception alert, and I can only see Ext js as root and nothing else. I appreciated if I can get some guidance, as I am brand new to ext and JSON.
thank you, jin