我想在用户从组合框到服务器的请求后显示一个窗口,其中包含有关错误的详细信息。如果我有异常,我将它放在json对象中并发送到cline side.Json对象就是这样。
{
{"error_message": "java.lang.NullPointerException: null"}
items: []
}
这是我发送和接收数据的代码的一部分。我试图在JsonStor的每个listerner中聊聊数据,但两者都不起作用,以下是实现。我正在使用ExtJs 3.4。
this.folderNameStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: this.config.folderNamesPath,
method: 'GET',
timeout: 120000
}),
listeners: {
beforeload: {
fn: function() {
var informaticaRepositoryId = this.getInformaticaRepositoryId();
if (informaticaRepositoryId) {
this.folderNameStore.setBaseParam('informatica_repository_id', informaticaRepositoryId);
}
},
scope: this
}
},
root: 'items',
idProperty: 'folder_name',
fields: ['folder_name']
});
// Custom rendering Template
resultTpl = new Ext.XTemplate('<tpl for="."><div class="informatica_workflow_command_folder_name-finder-item finder-item x-combo-list-item">', '<h2 class="name">{folder_name}</h2>', '</div></tpl>');
this.folderNameComboBox = new Ext.form.ComboBox({
allowBlank: false,
applyTo: "informatica_workflow_command_folder_name",
disabled: true,
displayField: 'folder_name',
forceSelection: false,
hideTrigger: false,
mode: 'remote',
itemSelector: 'div.informatica_workflow_command_folder_name-finder-item',
listClass: 'job-agents-combobox',
listEmptyText: helpsys.locale.javascript.no_matching_record,
loadingText: helpsys.locale.common.searching,
minChars: 4,
submitValue: false,
store: this.folderNameStore,
tpl: resultTpl,
triggerAction: 'all',
typeAhead: true,
maxLength: 80,
maxHeight: 400,
autoCreate: {tag: 'input', type: 'text', maxlength: '80'},
valueField: 'folder_name',
itemSelected: false,
oldValue: '',
listeners: {
change: function () {
this.updateFolderNameComboBox();
},
select: function () {
this.updateFolderNameComboBox();
},
keyup: function() {
this.updateFolderNameComboBox();
},
scope: this
}
});
this.updateFolderNameComboBox = function () {
if (this.folderNameComboBox.value == '') {
this.workflowNameComboBox.markInvalid();
} else {
if (this.folderNameComboBoxValue != this.folderNameComboBox.getValue()) {
this.workflowNameComboBox.markInvalid();
}
this.workflowNameComboBox.store.removeAll();
this.workflowNameComboBox.lastQuery = null;
this.workflowNameComboBox.enable();
this.folderNameComboBoxValue = this.folderNameComboBox.getValue();
}
};
答案 0 :(得分:2)
添加一个在商店加载时调用的函数: Ext.data.StoreManager.lookup('folderNameStore')。on('load',this.folderNameStoreLoaded);
然后在函数中执行类似Ext.getStore('folderNameStore')的操作.proxy.reader.jsonData
然后你可以在if语句中做出弹出通知 if(success ==“error”){Ext.MessageBox.alert('Oh No','Oh No!。');}
希望有所帮助。