0
votes

I just realized that alternate class names for controllers in ExtJS 4.2.1 don't work the way I expected them to:

Ext.define('AppName.controller.subnamespace.Controller1', {
    extend: 'Ext.app.Controller',
    alternateClassName: 'AppName.Ctrl1',
    // ...
});

Accessing the controller with the getController method of the app (or any controller) works for both names (the long one & the alternate one) but returns 2 distinct instances of the controller:

var ctrlInstance1 = AppName.app.getController('AppName.controller.subnamespace.Controller1'),
    ctrlInstance2 = AppName.app.getController('AppName.Ctrl1');

console.log(ctrlInstance1 === ctrlInstance2); // --> false

Is this intended behavior or a bug? If its a bug I'm going to file a bug report...

Thanks

Ps.: I've also asked this question in the official sencha forums but didn't get no response so far: http://www.sencha.com/forum/showthread.php?271970-Alternate-class-name-in-controller

1

1 Answers

0
votes

This is a sure way to write confusing code. Alternate class names feature was invented to provide backwards compatibility with previous Ext versions, where class names were different for certain components. It should not be used in the application code, unless you want to make your application harder to maintain.