I usually use the basic binding feature of the architect to listen to the "exception" event.
I am here however confronted to a case where my store is in the view model:
Code:
Ext.define('myProject.view.MyViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.mymodel',
requires: [
'Ext.data.Store',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json',
],
data: {},
stores: {
MyStore: {
autoLoad: false,
model: 'myProject.model.MyModel',
sortOnLoad: false,
proxy: {
type: 'ajax',
extraParams: {
},
reader: {
type: 'json',
messageProperty: 'message',
rootProperty: 'data'
}
}
}
}
});
Now I would like to have an exception handler, so the only option available to me in this context (basic event binding not being available) is: `View Controller Event Binding`
My proxy thus becomes:
Code:
proxy: {
type: 'ajax',
extraParams: {
},
reader: {
type: 'json',
messageProperty: 'message',
rootProperty: 'data'
},
listeners: {
exception: 'onAjaxException'
}
}
Which gives me the following exception when I try running the app:
[E] Ext.util.Event.getFireInfo(): No method named "onAjaxException" on Ext.data.proxy.Ajax
Why? Because — seeing is believing — architect decided to create the handler in the view controller (instead of the proxy which is inside the view model's stores):
Code:
Ext.define('myProject.view.MyViewController', {
extend: 'Ext.app.ViewController',
alias: 'controller.mycontroller',
onAjaxException: function(proxy, request, operation, eOpts) {
console.log('hello');
}
});
So the onAjaxException handler created by the architect is not found by the store's proxy (it's in a different file!).
Interestingly enough, if I manually create a Function in the proxy called "onAjaxException" it *does* run, but I can't get read of the wrongly created homonym in the view controller…
Pierre
EDIT: forgotten to attach my config:
Sencha Architect