1. #11
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Abstract classes are still a good idea IMO... Creating your own components sometimes you can just extend the abstract to accomplish what you need.
    True enough. Not all base classes are bad ... just some of them
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  2. #12
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    maksimenko is on a distinguished road

      0  

    Default


    Hi all,

    Well, after testing some cases, I'm really not liking this new behavior in Ext.override('...', {...});, maybe I'm still missing something,

    For example, in 4.1, I have a few overrides like this one:

    Code:
    Ext.override('Ext.layout.container.Fit', {
        calculate: function (ownerContext) {
            var me = this,
                childItems = ownerContext.childItems,
                /* begin workaround */
                //length = childItems.length, 
                length = childItems !== undefined ? childItems.length : 0, 
                /* end workaround */
                targetSize = me.getContainerSize(ownerContext),
                contentSize = { width: 0, height: 0 },
                i;
    
    
            for (i = 0; i < length; ++i) {
                me.fitItem(ownerContext, childItems[i], targetSize, contentSize);
            }
    
    
            if (!ownerContext.setContentSize(contentSize.width, contentSize.height)) {
                me.done = false;
            }
        }
    });
    but when Ext.layout.Context.runLayout runs, it calls layout.calculate(ownerContext), and, for a fit layout, the original calculate function is called instead of the override and thus it's giving me:
    "Uncaught TypeError: Cannot read property 'length' of undefined"... (This error happens when there is a panel without child items, just using the html: property, I can report it in another post if it helps)

    I understand and see the value of being able to have partial definitions of classes (coming from a .net world where partial classes are used somewhat widely), but maybe using another name instead of override, and let override do what the name suggest...

    Thanks again

  3. #13
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,015
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by dongryphon View Post
    True enough. Not all base classes a bad ... just some of them
    Can't disagree with that!
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #14
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by skirtle View Post
    I believe AbstractComponent and AbstractContainer exist so that the code can be shared with Sencha Touch.
    True.

    Quote Originally Posted by skirtle View Post
    If I've understood what Don said correctly, I believe these classes will disappear because the new style of overrides allow this code to be reused without the need for the abstract classes. They are still there in 4.1-pr1 though.
    They could, but not likely in 4.1. If we did, the AbstractComponent/Container names would become alternate names to maintain compatibility.
    Last edited by mitchellsimoens; 3 Nov 2011 at 11:09 AM. Reason: Let me fix that missing ']' for you :D
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  5. #15
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by maksimenko View Post
    when Ext.layout.Context.runLayout calls layout.calculate(ownerContext) for a fit layout, the original calculate function is called and is giving me:
    "Uncaught TypeError: Cannot read property 'length' of undefined"... (This error happens when there is a panel without child items, just using the html: property, I can report it in another post if it helps)
    Yes, that would help (in a new thread). The workaround in your override is attacking the symptom of a deeper problem. The childItems array should never be null, so there is something much more interesting afoot here.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  6. #16
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by maksimenko View Post
    Well, after testing some cases, I'm really not liking this new behavior in Ext.override('...', {...});, maybe I'm still missing something,

    I understand and see the value of being able to have partial definitions of classes (coming from a .net world where partial classes are used somewhat widely), but maybe using another name instead of override, and let override do what the name suggest...
    Override works as it did in 4.0, but callParent did change in 4.1. Is that the part you are not liking? Just curious because your example does not call the overridden method.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  7. #17
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    maksimenko is on a distinguished road

      0  

    Default


    Yep, I know that workaround should not be needed, but I'm doing those overrides so I can test the 4.1.

    I've used a few overrides for fixing problems that I got in 3.x, then in 4.0 and for sure, somewhere in the future I'd need some overrides to fix bugs until they are fixed in new releases (hopefully we'll be getting access to the 4.1 svn/git branch soon), so I need to find a reliable way to override some methods in ExtJS >= 4.1.

    I've tried modifying directly ext-all-dev and they let me use my app with a few quirks here and there, but no errors, and I'm very pleased with the performance improvements, but obviously this method shouldn't be used....

    I've tried doing the old school "Ext.layout.container.Fit.prototype.calculate = function (ownerContext) { ... };" for all my overrides, and although no error is raised, the app is not rendering as it is if I do the changes directly in ext-all-dev.... gotta investigate more why.

    So, that's why I'm raising this issue about Ext.override(''..", {..}); these kind of overrides worked on 3.x and 4.0, so, I'm trying to find a way to be able to override core methods reliably.

  8. #18
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    maksimenko is on a distinguished road

      0  

    Default


    Quote Originally Posted by dongryphon View Post
    Override works as it did in 4.0, but callParent did change in 4.1. Is that the part you are not liking? Just curious because your example does not call the overridden method.
    Hello Don, thanks for your response,

    Yup, in my tests, the override doesn't seems to be called, so that's the part I'm not liking (as I'm guessing more changes where done to that behavior, but maybe I'm wrong - I've not checked the core code to verify it -), I've no problem with the callParent change...

    My override isn't getting called (tried some console.log) when the runLayout calls layout.calculate(....) as it calls the overridden original method...

  9. #19
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by maksimenko View Post
    Yep, I know that workaround should not be needed, but I'm doing those overrides so I can test the 4.1.
    Understood. Still it would help if you could pass along whatever problems you are running into. It might be less investment on your part when the problems are too deep to just patch over.

    Thanks for digging in on the release!
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  10. #20
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by maksimenko View Post
    Yup, in my tests, the override doesn't seems to be called, so that's the part I'm not liking (as I'm guessing more changes where done to that behavior, but maybe I'm wrong - I've not checked the core code to verify it -), I've no problem with the callParent change...

    My override isn't getting called (tried some console.log) when the runLayout calls layout.calculate(....) as it calls the overridden original method...
    The form you have should work in both 4.0 and 4.1, give or take using the string class name. You could try removing the quotes on the class name you are overriding.

    You could try (in 4.1 only):

    PHP Code:
    Ext.define('My.patch.Fit', {
        
    override'Ext.layout.container.Fit',

        
    calculate: function () {
            ...
        }
    });

    //--- in your app:

    {
        
    layout'fit',
        
    requires'My.patch.Fit'

    With appropriate namespaces and pathing of course.

    This is a big part of why Ext.define/override was added in 4.1: to help manage overrides and when they are included in a build and when they can be (safely) applied to their target class.

    Hope this helps!
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"