View Full Version : ExtJS Namespaces doubts

11 Nov 2010, 12:27 PM
Hi everyone,

I'm a little confuse here trying to organize my classes. I don't know if I'm doing it right.

My actual class structure is like this (suppose OF is my company name):

/js/OF/OF.js (singleton OF)
/js/OF/Application/Application.js (OF.Application)
/js/OF/Viewport/Viewport.js (OF.Viewport)
/js/OF/Viewport/FivePanelViewport.js (OF.Viewport.FivePanelViewport

My question is.. I had this on my Viewport.js:

Ext.namespace( 'OF.Viewport' );

OF.Viewport = function( conf )
// Empty just for demostration purposes

OF.Viewport.superclass.constructor.call( this, conf );

Ext.extend( OF.Viewport, Ext.Viewport, { // more } );

And then in my FivePanelViewport.js:

OF.Viewport.FivePanelViewport.js = function( conf )
// Empty just for demostration purposes

OF.Viewport.FivePanelViewport.superclass.constructor.call( this, conf );

Ext.extend( OF.Viewport.FivePanelViewport, OF.Viewport, { // More } );

I define the namespace in the Viewport.js. But I need to have OF.Viewport class too, to define generic logic for all my custom Viewports.

Is this the right way to structure my classes within namespaces in JS / ExtJS?

Thanks in advance :)