3

I'm currently developing an Ext JS 6 application with some levels of inheritance on components, where some alias mappings get overridden. Ext JS debug is so friendly to let me know each time when I do this.

[W] Overriding existing mapping: 'controller.my-controller' From 'MyBase.app.Controller' to 'MySub.app.Controller'. Is this intentional?

In my case, it is intentional. The warnings are stacking up, and it is starting to get hard to see the forest for the trees.

  • Can I turn these statements off somehow just for those classes that are intentional?
  • Is renaming all my aliases a better solution?
Tarabass
  • 3,132
  • 2
  • 17
  • 35
levivanzele
  • 726
  • 1
  • 13
  • 33
  • If you're overriding the base controller alias, you just don't need an alias in it, right? – Elias Medeiros Jul 16 '15 at 13:27
  • I do seem to need it, since the view controller can otherwise not be found in the view if it is not also overridden. Also, I'd love a way to turn off the messages anyways! :) – levivanzele Jul 17 '15 at 06:05
  • I'd love to know how to turn it off, so I'll upvote your question. But what I meant was: your view will use the sub controller, right? Because you'll reference it by it's alias and your base controller alias was overrode, you can no longer reference it (the base controller) by alias. Since said alias is now useless, you can remove it from the base controller, or just change it. Sorry if I didn't make myself clear :) – Elias Medeiros Jul 17 '15 at 13:26
  • Ah, yes, I misunderstood your question. That's completely true, the base alias is useless then. – levivanzele Jul 18 '15 at 05:08

2 Answers2

3

I would recommend renaming your aliases.

Having two classes with the same alias might lead to problems when trying to instantiate one of them. There already is a great answer to this question for ExtJS 5 with a more detailed explanation. The core concepts are the same for ExtJs 6.

As an alias should always be unique (in it's namespace), it's probably a good idea to keep the warnings, just in case you ever miss something ... ;-)

If you really want to suppress these warnings anyway you could overwrite the Ext.log.warn function with an empty one. As you can see in ext/packages/core/src/class/Inventory.js there seems to be no other way around it.

Hope this answers your questions!

markusschmitz
  • 676
  • 5
  • 18
  • It partially answers the question. If nobody posts a way to hide the messages in a week or so I will flag this as the answer, assuming that it is impossible (within reason) to hide the warnings. – levivanzele Sep 28 '15 at 09:31
  • If you really want to suppress these warnings you could overwrite the Ext.log.warn function with an empty one. In production code this warning won't come up anyway. As you can see in ext/packages/core/src/class/Inventory.js there is no other way around it. – markusschmitz Sep 28 '15 at 18:38
  • I tend to avoid overrides, but I guess that'll have to do. Thanks for the extra info, it would be nice if you put it in the answer as well. – levivanzele Sep 29 '15 at 08:07
0

You can easily override the warning by forcing the "update" parameter to be set to true when addAlias calls addMapping.

Ext.Inventory.prototype.addAlias = function(className,alias, update) {
    return this.addMapping(className, alias, this.aliasToName, this.nameToAliases, true);
};

https://fiddle.sencha.com/#fiddle/1dec

Alexander
  • 19,906
  • 19
  • 75
  • 162