singleton windows

  • I am trying to have singleton windows (I only want the user to open up 1 of each, and I can't use closeAction hide since whether or not the user logged into the application determines in initComponent what the GUI looks like).

    I am trying the following but what I don't get is that I explicitly have to nullify the variable on the close of the window. There is also a memory leak problem with all my dialogs which might be related.

    Hope someone can help. TIA. Code is:


    var uploadContextWindow = null;

    mapfish.widgets.UploadContext.show = function(windowTitle, width, height) {
    if (uploadContextWindow === null) {
    uploadContextWindow = new Ext.Window({
    id: 'uploadcontext',
    title: windowTitle,
    width: width,
    height: height,
    layout: 'fit',
    cls: 'popup-variant1',
    plain: true,
    collapsible:true,
    items: new Ext.TabPanel({
    border: false,
    baseCls: 'x-tab',
    cls: 'x-tab-variant3',
    activeTab: mapfish.widgets.Login.getUser() ? 0 : 1,
    deferredRender: false,
    tabPosition: 'top',
    items: [ {
    title: 'Profiel',
    xtype: 'uploadcontext',
    disabled: !mapfish.widgets.Login.getUser(),
    map: map
    }, {title: 'Deze computer', xtype: 'uploadcontextfile', map: map} ], buttons: [{text: 'Sluiten', handler: function() { Ext.getCmp('uploadcontext').close(); }}] })
    });
    }
    uploadContextWindow.show();
    uploadContextWindow.on('close', function() { uploadContextWindow = null });
    uploadContextWindow.center();
    }


  • One of the approaches would be not to create/destroy window but to create only once, hide and when needed another time you'd just update context data (title, height, ...) and you'd show it. You can utilize closeAction:'hide' for this purpose.

    I'm using this approach successfully in one of my app, where I have several objects and one properties window for them. As I open the window for a particular object I "bind" it to that object such a way that properties of that object are edited. This binding is released on close (hide in fact).







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about singleton windows , Please add it free.