PDA

View Full Version : [FIXED] Unable to define exception event on RestProxy - me not defined



svenna
14 Aug 2012, 1:01 PM
ExtJs 4.1, Architect 2.1

I reported the same issue before, as bug DSGNR-1457
http://www.sencha.com/forum/showthread.php?183708-proxy-exception-codes-to-undefined-variable-me&highlight=Svenna

Back then it was with build 298. It seems like the bug has returned, or that my confirmation of the fix was incorrect.

This code gives an exception of "me is not defined"



Ext.define('BRes.model.Pulje', {
extend: 'Ext.data.Model',

idProperty: 'Id',

proxy: {
type: 'rest',
url: 'http://d-box.sventore.com/dev/bowlingres.no/webroot/rest/puljer/',
reader: {
type: 'json',
root: 'results'
},
writer: {
type: 'json',
writeAllFields: false
},
listeners: {
exception: {
fn: me.onRestproxyException,
scope: me
}
}
},

fields: [
{
name: 'Id',
type: 'int'
},
{
name: 'puljesegment',
type: 'int'
},
{
dateFormat: 'Y-m-d H:i:s',
name: 'start',
type: 'date'
},
{
name: 'plasser',
type: 'int'
},
{
name: 'segmentnavn'
},
{
name: 'startstr',
persist: false
},
{
name: 'antalldeltagere',
persist: false,
type: 'int'
}
],

onRestproxyException: function(server, response, operation, options) {
console.log(server,response,operation,options);
}

});

aconran
14 Aug 2012, 1:05 PM
Hrm, we don't allow users to put in event handlers for a proxy when it is associated with a model.

Could you provide steps for how you were able to create this?

svenna
14 Aug 2012, 1:20 PM
Hum..

Create Model, Add Proxy to model, then on the proxy click "Event Bindings" + icon.
The drop-down appearing only have the one option: 'exception'.

I've done it like this since the "Event Bindings" option was added.

However I can also drag the Basic Event Binding over to the proxy.

If this is not supposed to work. How am I supposed to catch server error messages for the REST proxy? And how should it be done within Architect? - except with an override. In my case overriding all rest proxies would be an option.


Image attached

37958

aconran
14 Aug 2012, 1:46 PM
Okay, so first off I agree that there is a bug (or possibly several rolled into one) with this.



However I can also drag the Basic Event Binding over to the proxy.
I cannot reproduce this. I created a model. I added a RestProxy to the model. I cannot drag/drop a basic event binding and or create via "Event Bindings" in the property grid.



If this is not supposed to work. How am I supposed to catch server error messages for the REST proxy? And how should it be done within Architect?

We probably need to change this so that the proxy is constructed within the constructor of the model similar to how we do stores.

svenna
14 Aug 2012, 10:06 PM
I've done this in more than one project, I can email you the project I'm working on now, just need a preferred address.

aconran
14 Aug 2012, 10:08 PM
aaron at sencha

blum@wapa.gov
3 Dec 2012, 9:44 AM
I know this thread is a bit old but there is an easy workaround - just add 'listeners' as a Custom property to the proxy. In my case that looks like this as shown in the Architect editor:


listeners - object <-- editor box header
// NOTE - this code added as a custom property to the Proxy, not via 'Event Bindings'
// When added as an event the listener function call attempts to use a 'me' reference
// & proxies have no 'me'.
{
exception: {
fn: function(pxy, response, operation, options){
WhatEver();
}
}
}

svenna
4 Dec 2012, 12:02 AM
Thanks for the Tip. after e-mailing with Aron he found that in my project, that was created before Architedt disabled exceptions I could add exceptions to a model proxy, but not when creating a new project.

Aron commented that they would likely allow it again new relases. Since I'm still working on the same projects I havent noticed it there is a change yet.