PDA

View Full Version : How to adjust NestedActions(Ext.direct.RemotingProvider) to Sencha Touch 2.3



Kazuhiro Kotsutsumi
6 Nov 2013, 3:54 PM
NestedActions is a new feature provided from Ext JS 4.2.

However, We cannot use even Sencha Touch 2.3.

Therefore I made the patch such as follows.



/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

// {{{ Ext.overrides.direct.RemotingProvider

/**
* Ext.overrides.direct.RemotingProvider
*
* Copyright (c) 2013 Xenophy.CO.,LTD All rights Reserved.
* http://www.xenophy.com
*/
Ext.define('Ext.overrides.direct.RemotingProvider', {

// {{{ override

override: 'Ext.direct.RemotingProvider',

// }}}
// {{{ initAPI

initAPI: function() {

var me = this,
getNamespace, createNamespaces;

// {{{ getNamespace

getNamespace = function(root, action) {

var parts, ns, i, l;

root = root || Ext.global;
parts = action.toString().split('.');

for (i = 0, l = parts.length; i < l; i++) {

ns = parts[i];
root = root[ns];

if (typeof root === 'undefined') {
return root;
}
}

return root;
};

// }}}
// {{{ createNamespaces

createNamespaces = function(root, action) {

var parts, ns;

root = root || Ext.global;
parts = action.toString().split('.');

for ( var i = 0, l = parts.length; i < l; i++ ) {

ns = parts[i];

root[ns] = root[ns] || {};
root = root[ns];
};

return root;
};

// }}}

var actions = me.getActions(),
namespace = me.getNamespace(),
action, cls, methods,
i, ln, method;

for (action in actions) {

if (actions.hasOwnProperty(action)) {

if (me.disableNestedActions) {

cls = namespace[action];

if (!cls) {
cls = namespace[action] = {};
}

} else {

cls = getNamespace(namespace, action);

if (!cls) {
cls = createNamespaces(namespace, action);
}
}


methods = actions[action];

for (i = 0, ln = methods.length; i < ln; ++i) {
method = Ext.create('Ext.direct.RemotingMethod', methods[i]);
cls[method.getName()] = me.createHandler(action, method);
}
}

}

}

// }}}

});

// }}}

/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* c-hanging-comment-ender-p: nil
* End:
*/



You should load this class.

Have a good coding!

fmoseley
8 Nov 2013, 4:03 PM
Thanks for sharing.