Results 1 to 6 of 6

Thread: Problem and solution about Model with Ext.Direct proxy

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    8
    Vote Rating
    0
      0  

    Default Problem and solution about Model with Ext.Direct proxy

    I found a problem that Model with direct proxy failed to initialize, especially after app was built. It showed error messages like "Uncaught TypeError: Cannot read property 'directCfg' of null" when the Model try to call proxy.
    Because the Model class try to create instance of proxy when the class is defined ( not when the class is instanciated).
    The Direct proxy evaluates directFn only when it is set at applyDirectFn. To prevent failure, I extended Ext.data.proxy.Direct class. This class evaluates directFn whenever it is obtained at getDirectFn.

    Code:
    Ext.define('SevenDays.proxy.DirectWithStringFn', {
        extend : 'Ext.data.proxy.Direct',
        alias : 'proxy.directWithStringFn',
        requires : [ 'Ext.data.proxy.Direct' ],
    
    
        applyDirectFn : function(directFn) {
            //<debug>
            if (!Ext.isString(directFn)) {
                console.log('directFn must be string.');
            }
            //</debug>
            return directFn;
        },
        getDirectFn : function() {
            var me = this;
            var directFn = me.callParent(arguments);
            //<debug>
            if (!Ext.isString(directFn)) {
                console.log('directFn must be string.');
            }
            //</debug>
            return Ext.direct.Manager.parseMethod(directFn);
        }
    });
    I consider that it is better to keep directFn once it is parsed correctly.
    Last edited by hosokaws; 12 Jul 2013 at 3:02 AM. Reason: To add specific error message

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Vote Rating
    1297
      0  

    Default

    Is this for touch or ext js?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Is this for touch or ext js?
    My environment was touch. But an application not built couldn't caused the error.
    After .js files are built to one app.js, own model classes extended from Ext.data.Model are defined before calling Ext.direct.Manager.addProvider. So it failed to parse directFn in Ext.direct.Manager.parseMethod.
    I'm not sure about ext js. But if ext js has a functionality about building an application, it may cause same error.

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Vote Rating
    1297
      0  

    Default

    Touch 2.3 branch, I've made a change that it won't try to parse the method until the first load instead of instantiation of the proxy.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

  5. #5
    Sencha User
    Join Date
    Jul 2013
    Posts
    1
    Vote Rating
    0
      0  

    Default

    Touch 2.3 branch, I've made a change that it won't try to parse the
    method until the first load instead of instantiation of the proxy.<br><br>

  6. #6
    Sencha User
    Join Date
    Jan 2013
    Posts
    8
    Vote Rating
    0
      0  

    Default

    That's nice! I'm looking forward to Touch 2.3.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •