View Full Version : struts2 Extjs-Tree Json array problem

10 Feb 2010, 3:12 PM
Hello everyone,
I am new to ExtJs and I am just having a hard time reading the json array received from struts2 application.

Following is the json array that I received from struts application

[{"children":[{"children":[],"cls":"file","id":11,"leaf":true,"text":"A Child 1"},{"children":[],"cls":"file","id":12,"leaf":true,"text":"A Child 2"}],"cls":"folder","id":10,"leaf":false,"text":"A Folder"}]

it works fine if I save it in the .json file and call it using dataUrl: 'json.json'. But when I call it using dataUrl: 'myAction.action', the data is not loaded.

I would really appreciate if someone could throw some insight on something I am missing here. Following is my .js, which is similar to example provided by extjs

// shorthand
var Tree = Ext.tree;

var tree = new Tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl: 'myAction.action',

root: {
nodeType: 'async',
text: 'Ext JS',
draggable: false,
id: 'src'

// render the tree

10 Feb 2010, 5:07 PM
are you just changing the name of the file or is there something more you're doing?

10 Feb 2010, 5:47 PM
Well I am trying to make this simple example work so that I can think of something bigger. Thanks for the response tho.