Hello, I'm new to ExtJS and had a question about namespaces. I understand the reasons to use them (for organization and to prevent class collisions within an application).
In Java, the norm is to create packages with very specific names. These can often be long, e.g. "com.mycompany.widgets.gwt.myapp.controller", etc.
The reasons for this are probably obvious, since building a Java app essentially merges all of the namespaces of all of the libraries in use, so careful thought must be given to prevent overlap and collisions.
When it comes to Ext namespaces, is this as much of a concern? If a single web page has separate iframes or windows in it (like a portal), is there a danger that namespaces across separate apps/frames can collide?
Basically, I'm wondering how far people take the namespaces.
Thanks, I had read that but it doesn't say much beyond the fact that packages organize your code. I'm trying to get deeper and determine what the benefits are beyond organization. Mainly, under what conditions will namespaces conflict (in the same application? In the same frame?), how concerned I should be about this, and what is the best way to avoid it.
Having said that, I still think namespacing helps keep you from stepping on your own toes as an application grows in size and scope.
Great, that helps. So to clarify further, the only real danger of namespace collision is if your application is using some external code with the same namespace? And if you're running your app in a portal (like a "widget" in its own iframe), there won't be conflicts with apps in other iframes? In other words, each iframe would be self-contained from a namespace perspective because they're all separate apps running on separate pages.
Ext is a globally scoped reference. You can test this by doing window.Ext.getVersion().version == Ext.getVersion().version .
That said, you should not have to worry about collisions if you use a unique namespace identifier (Global reference) for your applications. Couple that with lexically scoped references, and you should be OK
Each iframe is its own "sandbox", where they each have their own global pool of references. So, you can have N number of instances of Ext JS running on a single page with frames. I highly discourage that practice, as it's inefficient and extremely difficult to debug.
Ext JS was not designed to deal with multiple frames.
Hmm...now I feel like I need to dig a bit deeper. We're working on an application that is essentially a portal. There is a "shell" application (which happens to be an ExtJS app) where users can manage their portal and add "widgets" (basically, portlets) to their workspace. These are written in a range of ways: some are ExtJS, some are Flex, some are GWT, etc. Each widget is loaded into an iframe from where ever they are hosted (they may be coming from a range of locations internal to the enterprise). The different widgets only communicate with the outer "shell" application (or with each other) through a very specific API that is very generic (since it has to be usable by many different widgets using different technologies).
The portal seems to handle all of this just fine. I'm really just trying to make sure that different ExtJS apps loaded into separate widget iframes aren't going to step on each other in some way. They *should* all have different application names anyway, but since they're running in separate iframes it seems like this should isolate them completely.
If that clarifies my situation enough, can you confirm?