我是EXTJS的新手。我使用的是旧版本的3.4版本。 定义了控制器并使用DirectMethod填充组合框值。
但是控制器的直接方法没有被调用。
public class Controller { //Controller to fetch the data
@DirectMethod
public String fetchData() {
System.out.println("Controller");
ArrayList < ComboDataVo > da = null;
Dao dao = new Dao();
try {
da = dao.retrieveUserData();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("In Controller.................");
Gson gson = new GsonBuilder().serializeNulls().create();
System.out.println("Data: " + gson.toJson(da));
return gson.toJson(da);
}
}
Ext.onReady(function() {
//Menu
new Ext.Toolbar({
renderTo: document.body,
items: [{
xtype: 'tbbutton',
text: 'Button',
helpfile: 'director',
handler: Movies.showHelp
}, {
xtype: 'tbfill'
}, {
xtype: 'tbseparator'
}, {
xtype: 'tbbutton',
text: 'Menu Button',
menu: [{
text: 'Panel1'
}, {
text: 'Panel2'
}]
}]
})
//Form
Ext.QuickTips.init();
var movie_form = new Ext.FormPanel({
renderTo: document.body,
frame: true,
width: 800,
collapsible: true,
title: 'Movie Information',
items: [{
xtype: 'checkbox',
name: 'mtype',
fieldLabel: 'Horror Movie'
}, {
fieldLabel: 'Local Data',
xtype: 'combo',
name: 'genre',
mode: 'local',
store: dstore, // Calling this one for the Combo data
displayField: 'user_id'
}, {
xtype: 'textarea',
fieldLabel: 'Decription',
anchor: '100%',
maxLength: 5
}, {
fieldLabel: 'extra Comments',
xtype: 'htmleditor',
anchor: '100%'
}, {
xtype: 'panel',
title: 'Panel',
layout: 'border',
collapsible: true,
items: [{
xtype: 'textfield',
fieldLabel: 'PanelTextBox1',
name: 'panelTxt1',
region: 'west'
}, {
xtype: 'textfield',
fieldLabel: 'PanelTextBox2',
name: 'panelTxt2',
region: 'south'
}]
}]
});
});
//Data Store js
var dstore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['user_id', 'emp_no']
}),
proxy: {
type: 'direct',
directFn: 'Controller.fetchData'
},
autoLoad: true
});
有人可以帮我这个吗? 感谢您的帮助!
谢谢, Dhaval