[OPEN] [#257] Namespace and ID issue in v2.2

Page 2 of 5 FirstFirst 1234 ... LastLast
  1. #11
    Unfortunately, this will work only on page_load events. For any DirectEvent it would not recognise the ID.
  2. #12
    ItemID is not Unique. But combination of ItemID and Namespace are unique.
    Why don't you want to use unique ID only?

    Unfortunately, this will work only on page_load events. For any DirectEvent it would not recognise the ID.
    Not sure that understood it correctly, if ID is unuque then should not be any problem

    IMHO, you should minimize ID using for client side referencing, use component query (http://docs.sencha.com/ext-js/4-2/#!...ComponentQuery) and message bus
    We use ID in our examples only for simplifying
  3. #13
    Hi Vlad,
    I am sorry to be troubling you. But do you think there can be a better way in the framework itself to handle such situation.
    Even if bug, the old solution was better to handle the Server and Client sides seperately. It was perfect. I always assumed ItemID to be client side id and ID to be server side id and it always worked well.

    I am sure lot of people will face this problem upgrading the solution. Can you please look into it?

    I will hold migrating to v2.2 for now but continue testing.

    Thanks,
  4. #14
    Why don't you want to use unique ID only?
    I can have a team working on different forms. Each form has its namespace. How can I manage to have unique client id's across the team? If 2 people our working on a form, there are very high chances that they both would name the button "btnSubmit" because its a submit button. Its difficult to co ordinate and 1st figure out if anyone else has used the same ID. Forget team, even I won't remember if I have used same ID in a different form. But I can ensure its unique with a control. That's workable.

    Not sure that understood it correctly, if ID is unuque then should not be any problem

    IMHO, you should minimize ID using for client side referencing, use component query (http://docs.sencha.com/ext-js/4-2/#!...ComponentQuery) and message bus
    We use ID in our examples only for simplifying
    Try setting IDMode Ignore on a panel with ID, ItemID. And update its html in direct event. It will throw the error
    You have to set widget's ID to call its methods (widget - Ext.Net.Panel)

    We have structured our application on Control inside a Namespace. Its far more easier for us to handle while debugging on client side. Namespcae->Control structure is much more intuitive than querying Component Query.

    I don't know much about MessageBus, but I will surely try in future projects. Not now. We will have to change a lot to just accomodate just one ID issue.

    Apart from this, I think, if this was a known issue, it could have been fixed in SVN 2.1 branch long back. And I absolutely see no issue in retaining the earlier way, even if a bug. It looks like a bug in theory, but who cares if it gets convenience and clarity?
  5. #15
    But do you think there can be a better way in the framework itself to handle such situation.
    How the framework can handle it? The framework can check ids only, it cannot change (or something else) id

    Even if bug, the old solution was better to handle the Server and Client sides seperately. It was perfect. I always assumed ItemID to be client side id and ID to be server side id and it always worked well.
    Well, the main reason why you don't want to use ID with IDMode=Static is that you cannot control that ID is unique. How do you control ItemID uniqueness?

    I am sure lot of people will face this problem upgrading the solution. Can you please look into it?
    Well, i will not consider it as problem. There is ID (it is server side ID), it should be unique within own INamingContainer (or Page, if INamingContainer is absent). There is ClientID (which we use to share client side instance), it is generated from ID according to IDMode and ClientIDMode (if you under .NET 4). For Ext.Net widgets, ClientID = Namespace + ConfigID (ConfigID is just ASP.NET ClientID (not overriding ClientID))

    By default, ID == ConfigID if a widget is not inside INamingContainer (INamingContainer is UserControl, MasterPage, Repeater and etc)
    You can chage ClientID generation behaviour by using IDMode and ClientIDMode (choose generation strategy which satisfy you) (ASP.NET 4 uses the same approach via ClientIDMode)

    Thats all what framework can give you, checking ID uniqueness is developer responsibility.
    ItemID is ExtJS feature, it is not designed for global sharing (only for local searching using component query), we made one exception only: if control has no ID and has own Namespace (not inherited) then ItemID is shared in that namespace

    I can have a team working on different forms. Each form has its namespace. How can I manage to have unique client id's across the team? If 2 people our working on a form, there are very high chances that they both would name the button "btnSubmit" because its a submit button. Its difficult to co ordinate and 1st figure out if anyone else has used the same ID. Forget team, even I won't remember if I have used same ID in a different form. But I can ensure its unique with a control. That's workable.
    Again, how do you control uniqueness of ItemID? Therefore ClientID is not equal ID inside INamingContainer (to ensure uniqueness of ClientID), but you want to disable concating with parent id to referecing by direct id on the client side (you want panel1 instead test_panel1)

    Try setting IDMode Ignore on a panel with ID, ItemID. And update its html in direct event. It will throw the error
    You have to set widget's ID to call its methods (widget - Ext.Net.Panel)
    I will investigate this case. If control has own Namespace and ItemID (and no ID) then should not be such exception

    We have structured our application on Control inside a Namespace. Its far more easier for us to handle while debugging on client side. Namespcae->Control structure is much more intuitive than querying Component Query.
    Intuitive yes, but you had problems like you described (uniqueness of ID)

    If you like ItemID sharing then you can use old code (from v2.1)
    Ext.net.ComponentManager.registerId  = function (cmp) {
            if (cmp.initDirectEvents) {
                cmp.initDirectEvents();
            }
    
    
            if (cmp.initialConfig || cmp.isStore || cmp.proxyId) {
                var cfg = cmp.initialConfig || {},
                    id = cmp.isStore ? cmp.storeId : (cmp.proxyId || cfg.proxyId || cfg.id),
                    ns = cmp.ns || (Ext.isArray(Ext.net.ResourceMgr.ns) ? Ext.net.ResourceMgr.ns[0] : Ext.net.ResourceMgr.ns),
                    hasId = (!Ext.isEmpty(id, false) && id.indexOf("ext-comp-") !== 0);
                
                if (cmp.forbidIdScoping !== true && ( hasId || (cmp.ns && !Ext.isEmpty(cmp.itemId, false)) ) ) {
                    if (ns) {                    
                        (Ext.isObject(ns) ? ns : Ext.ns(ns))[hasId ? id : cfg.itemId] = cmp;
                        cmp.nsId = (Ext.isObject(ns) ? "" : (ns + ".")) + (hasId ? id : cfg.itemId);
                    } else {
                        window[id] = cmp;
                        cmp.nsId = id;
                    }
                }
            }
        };
  6. #16
    How the framework can handle it? The framework can check ids only, it cannot change (or something else) id


    Well, the main reason why you don't want to use ID with IDMode=Static is that you cannot control that ID is unique. How do you control ItemID uniqueness?
    I control the uniqueness with Namespace and ItemID configuration. So my btnSubmit would be Controls.Search.btnSubmit and Export.btnSubmit. Both are unique within their namespace and I can access them in the code behind too within their respective user controls. I actually don't know where is the bug there. It looks actually only in theory.

    May be you are not understanding what I am trying to say. Can you run the example I have you in 2.1 and 2.2 and try accessing those contorls on client side? You will see the difference in naming.


    Well, i will not consider it as problem. There is ID (it is server side ID), it should be unique within own INamingContainer (or Page, if INamingContainer is absent). There is ClientID (which we use to share client side instance), it is generated from ID according to IDMode and ClientIDMode (if you under .NET 4). For Ext.Net widgets, ClientID = Namespace + ConfigID (ConfigID is just ASP.NET ClientID (not overriding ClientID))

    By default, ID == ConfigID if a widget is not inside INamingContainer (INamingContainer is UserControl, MasterPage, Repeater and etc)
    You can chage ClientID generation behaviour by using IDMode and ClientIDMode (choose generation strategy which satisfy you) (ASP.NET 4 uses the same approach via ClientIDMode)

    Thats all what framework can give you, checking ID uniqueness is developer responsibility.
    ItemID is ExtJS feature, it is not designed for global sharing (only for local searching using component query), we made one exception only: if control has no ID and has own Namespace (not inherited) then ItemID is shared in that namespace


    Again, how do you control uniqueness of ItemID? Therefore ClientID is not equal ID inside INamingContainer (to ensure uniqueness of ClientID), but you want to disable concating with parent id to referecing by direct id on the client side (you want panel1 instead test_panel1)
    I am considering the following cases here.

    ID=Server ID
    ItemID = ClientID
    Namespace = To give uniqueness to each user control and a scope for the controls inside namespace.

    IDMode for ServerID can just be for server access. ItemID can be the client ID. Again its uniqueness will be confined to the namespace. In namespace, 2 id's cannot be same obviously. But in my case, I am keeping it unique by having 2 different namespaces.



    I will investigate this case. If control has own Namespace and ItemID (and no ID) then should not be such exception
    Make sure u specify ID, ItemID and Namespace and idmode=ignore. And then test. If this works. All works as expected.

    Intuitive yes, but you had problems like you described (uniqueness of ID)
    I never had problem of uniqueness, because control ID was unique within its UserControl, and unique within its namespace.

    If you like ItemID sharing then you can use old code (from v2.1)
    Ext.net.ComponentManager.registerId  = function (cmp) {
            if (cmp.initDirectEvents) {
                cmp.initDirectEvents();
            }
    
    
            if (cmp.initialConfig || cmp.isStore || cmp.proxyId) {
                var cfg = cmp.initialConfig || {},
                    id = cmp.isStore ? cmp.storeId : (cmp.proxyId || cfg.proxyId || cfg.id),
                    ns = cmp.ns || (Ext.isArray(Ext.net.ResourceMgr.ns) ? Ext.net.ResourceMgr.ns[0] : Ext.net.ResourceMgr.ns),
                    hasId = (!Ext.isEmpty(id, false) && id.indexOf("ext-comp-") !== 0);
                
                if (cmp.forbidIdScoping !== true && ( hasId || (cmp.ns && !Ext.isEmpty(cmp.itemId, false)) ) ) {
                    if (ns) {                    
                        (Ext.isObject(ns) ? ns : Ext.ns(ns))[hasId ? id : cfg.itemId] = cmp;
                        cmp.nsId = (Ext.isObject(ns) ? "" : (ns + ".")) + (hasId ? id : cfg.itemId);
                    } else {
                        window[id] = cmp;
                        cmp.nsId = id;
                    }
                }
            }
        };
    Thanks for the code. I will try it.
  7. #17
    Hi Vlad,
    Your code worked but had to make couple of minor changes.

    Just one more issue which is, when I use #{btnSubmit} in handler, it returns server id instead of itemid so something like ctl02_panel1_btnSubmit instead of Controls.Panel.btnSubmit.
  8. #18
    Also could you look into ignore issue?
  9. #19
    Just one more issue which is, when I use #{btnSubmit} in handler, it returns server id instead of itemid so something like ctl02_panel1_btnSubmit instead of Controls.Panel.btnSubmit.
    In which case? If ID is defined then ID will be used
  10. #20
    Quote Originally Posted by Vladimir View Post
    In which case? If ID is defined then ID will be used
    Hi Vlad,
    You gave me a solution for client side access of control's id with their itemid even if ID and ItemID are specified. The solution you gave me works for Code Behind also.

    Just that when it transforms # tag to actual id, it should return NameSpace.ItemId. How do I ensure that?

    I don't think you are taking my issue too seriously. I cannot even think of upgrading to 2.2 until this issue is completely resolved. So plz tell me how do I ensure even # tokens are converted to NameSpace.ItemID like it did in 2.1
Page 2 of 5 FirstFirst 1234 ... LastLast

Similar Threads

  1. Help with TreeNode namespace
    By zXSwordXz in forum 2.x Help
    Replies: 4
    Last Post: Oct 27, 2012, 3:36 AM
  2. [CLOSED] 'Model' is a namespace but is used like a 'type'
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 10, 2012, 3:12 PM
  3. Ext.Net.Calender Namespace
    By Rupesh in forum 1.x Help
    Replies: 5
    Last Post: Feb 24, 2012, 12:56 PM
  4. [CLOSED] Namespace Does not register
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Nov 07, 2011, 10:10 AM
  5. [CLOSED] [MVC] namespace issue I think
    By pkellner in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Sep 30, 2008, 11:47 AM

Posting Permissions