如何使用来自控制器的ajax调用java servlet

时间:2013-05-07 09:47:06

标签: extjs4 extjs4.1 extjs-mvc

我在我的控制器中创建了一个条形图..我想调用一个servlet ..在我的函数中,我使用一个变量来保存使用getStore('StoreName')的商店的instacne ..现在怎样才能调用AJAX ???请有人帮助我..这是我的控制器...

Ext.define('Gamma.controller.ControlFile', {    
extend : 'Ext.app.Controller', 
//define the stores
stores : ['BarColumn','RadarView','VoiceCallStore','SMSCallStore','MMSCallStore','GPRSUsageStore'],
//define the models 
models : ['BarCol','radar','VoiceCallModel','SMSCallModel','MMSCallModel','GPRSUsageModel'],
//define the views
views : ['BarColumnChart','LineChart','RadarChart','VoicePie','SMSPie','MMSPie','GPRSPie'],

initializedEvents: false,
init: function() {
    this.control({
        '#barColumnChart': {
            afterlayout: this.afterChartLayout
        }
    });
},
afterChartLayout: function(){
    var me=this;
    if(this.initializedEvents==true) return;
    this.initializedEvents=true;
    Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){
        var barData=obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count'];
            me.dataBaseCall(barData);
    });
},
dataBaseCall: function(barData){
    var bar=getStore('BarColumn');

    //here I want to call the ajax

}

});

这是我的商店代码栏图表..

Ext.define('Gamma.store.BarColumn', {
extend: 'Ext.data.Store',
model: 'Gamma.model.BarCol',
autoLoad: true,
pageSize: 100,

  proxy: {
    type: 'ajax',
    url: '../TopCount', //this my servlet name
    reader: {
        type: 'json',
        root: 'topList',
        totalProperty: 'totalCount',
        successProperty: 'success'
    }
}
});

1 个答案:

答案 0 :(得分:0)

使用控制器块中的以下代码

dataBaseCall:function(barData){     var bar = getStore('BarColumn');

 var store = Ext.create('Gamma.store.BarColumn');

 // to create storeid use below code
  var store = Ext.create('Gamma.store.BarColumn', {storeId: 'BarColumnID'});

}