[code="java"]
Ext.define('Person', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
],
proxy: {
type: 'ajax',
api: {
create: 'createPersons',
read: 'getData.jsp',
update: 'updatePersons',
destroy: 'destroyPersons'
}
}
});
Ext.onReady(function(){
var store = Ext.create('Ext.data.TreeStore', {
model: 'Person',
root: {
name: 'People',
expanded: true
}
});
Ext.create('Ext.tree.Panel', {
renderTo: Ext.getBody(),
width: 300,
height: 200,
title: 'People',
store: store,
columns: [
{ xtype: 'treecolumn', header: 'Name', dataIndex: 'name', flex: 1 }
]
});
});
[/code]
[code="java"]
<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String result = "{'root':'People','success':true,'children':[{'id': 1,'name':'Phil','leaf':true},{'id':2,'name':'Nico','expanded':true,'children':[{'id':3,'name':'Mitchell','leaf':true}]},{'id':4,'name':'Sue','loaded':true}}";
System.out.println("sss");
out.write(result);
response.getWriter().write(result);
%>
[/code]