Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 36

Thread: DirectProxy need work

  1. #21
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Quote Originally Posted by deemonas View Post
    I see error: directFn.apply is not a function
    In doRequest it assigns either me.api[operation.action] or me.directFn to a local variable called directFn.

    Looks like it's expected read to now reference your direct function rather than a URL, since later it does directFn.apply(window, args);

    So something like:
    Code:
    api: {
        read: Namespace.action.method
    }
    Where the Namespace.action.method is as defined in the JavaScript returned by your direct router.

    Hope that helps,
    Westy

  2. #22
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Progress... have written some server-side code to create and build an instance of an object parameter to the direct method in question.

    Issue now is, since I've not put any data in my database, it's returning an empty array.
    This manifests itself in the JSON as result: [].

    This means result.success is false, which means I then get an error when the exception event is fired from DirectProxy.

    Code:
        createCallback : function(request, operation, callback, trans, scope) {
            var me = this,
                action = operation.action;
    
            return function(result, req) {
                if (!result.success) {
                    me.fireEvent('exception', me, 'remote', action, trans, res, null);
    //...
    Should res be req?

    Cheers,
    Westy

  3. #23
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451

    Default

    Quote Originally Posted by deemonas View Post
    Hello,

    In Ext 3.x I used this config:

    Code:
                                                
    proxy: new Ext.data.HttpProxy({
                                                    api: {
                                                        read : '/ajax/?action=read',
                                                        create : '/ajax/?action=create',
                                                        update: '/ajax/?action=update',
                                                        destroy: '/ajax/?action=destroy'
                                                    }
                                                });
    Now , when I try it in Ext 4 and your version:

    Code:
        proxy: {
            type: 'direct',
            url : '/ajax/',
            extraParams : { ajax : 'testing'},
            api: {
                read : '/ajax/?action=read',
                create : {url: '/ajax/?action=create'},
                update: {url: '/ajax/?action=update'},
                destroy: '/ajax/?action=destroy'
            }
        }
    I see error: directFn.apply is not a function
    [IMG]chrome://firebug/content/blank.gif[/IMG]directFn.apply(window, args);

    I had never used directFn before. I just need proxy to POST on specified in api URLs. Any suggestions ?
    You are not using Direct properly. You are using more of a REST style.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #24
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    I suspect when method being called returns null or an empty collection I should be getting:
    Code:
    result": {
            "success": true,
            "total": "0",
            "data": []     // Or maybe no data element at all.
    }
    Sounds like a bug in the Direct router... will sort it.

  5. #25
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451

    Default

    Quote Originally Posted by westy View Post
    Should res be req?
    Probably. Forgot to touch the exception event. Wasn't an issue since mine is working
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #26
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Quote Originally Posted by westy View Post
    I suspect when method being called returns null or an empty collection I should be getting:
    Code:
    result": {
            "success": true,
            "total": "0",
            "data": []     // Or maybe no data element at all.
    }
    Sounds like a bug in the Direct router... will sort it.
    My assumption here was incorrect.

    The Ext.Direct spec indicates that the result can be anything; it's simply the return from the method.

    Looks like this proxy version differs from the v3 one in the fact that it checks the result object for a success member rather than checking the second parameter to the callback's (res) status member.
    A small point but could mean that some rework is required when the official version hits.

  7. #27
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Fairly fundamental bug fix for others that may be using this, although I understand it works fine for you Mitchell, although no idea how TBH, given this fix.

    Change to createCallback:
    Code:
        createCallback : function(request, operation, callback, trans, scope) {
            var me = this,
                action = operation.action;
    
            return function(result, res) {
                if (!res.status) {
                    me.fireEvent('exception', me, 'remote', action, trans, res, null);
                    trans.request.callback.call(me, operation);
                    return;
                }
                if (action === "read") {
                    me.onRead(operation, action, trans, result, res, callback, scope);
                } else {
                    me.onWrite(operation, action, trans, result, res, rs);
                }
            };
        },
    Fairly crucial bit, since original wanted a 'success' member in your result, and there should be no imposed members to what data we return. The 'res' object is part of how Ext.Direct works I believe.

    Anyway, is now working for me, so I'm happy, can crack on with getting some real data flying about

    Regards,
    Westy

  8. #28
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451

    Default

    Quote Originally Posted by westy View Post
    Fairly fundamental bug fix for others that may be using this, although I understand it works fine for you Mitchell, although no idea how TBH, given this fix.

    Change to createCallback:
    Code:
        createCallback : function(request, operation, callback, trans, scope) {
            var me = this,
                action = operation.action;
    
            return function(result, res) {
                if (!res.status) {
                    me.fireEvent('exception', me, 'remote', action, trans, res, null);
                    trans.request.callback.call(me, operation);
                    return;
                }
                if (action === "read") {
                    me.onRead(operation, action, trans, result, res, callback, scope);
                } else {
                    me.onWrite(operation, action, trans, result, res, rs);
                }
            };
        },
    Fairly crucial bit, since original wanted a 'success' member in your result, and there should be no imposed members to what data we return. The 'res' object is part of how Ext.Direct works I believe.

    Anyway, is now working for me, so I'm happy, can crack on with getting some real data flying about

    Regards,
    Westy
    Tested fix on my working Grids and it works so I pushed this change to my GitHub repo also. Great job and keep it up :-) Is everything working for you as far as reading goes?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  9. #29
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Tested fix on my working Grids and it works so I pushed this change to my GitHub repo also. Great job and keep it up :-)
    Excellent, and thanks

    Quote Originally Posted by mitchellsimoens View Post
    Is everything working for you as far as reading goes?
    Just writing a script to put some test data in my database... should be done in the next half hour, then will try it.
    I'm confident that the router and DirectProxy are sorted now though /fingers-crossed

    Cheers,
    Westy

  10. #30
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Hmm, have data coming back now, but is slightly the wrong shape due to a JSON serialization issue I think.

    Would expect an error of some kind in this case, but just seem to have a quarter height row on my grid with nothing in it... will investigate further tomorrow...

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. DataWriter Example does not work with DirectProxy
    By jcalfee in forum Ext.Direct
    Replies: 4
    Last Post: 12 Oct 2010, 12:40 PM
  2. [FIXED-672] DirectProxy Issue and Fix
    By timothy in forum Ext 3.x: Bugs
    Replies: 4
    Last Post: 4 Mar 2010, 9:37 AM
  3. Ext.data.DirectProxy doesn't work for me. What's wrong?
    By iryndin in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 18 Nov 2009, 9:57 AM
  4. How to use PARAMS with Ext.data.DirectProxy
    By kpopov in forum Ext.Direct
    Replies: 1
    Last Post: 10 Sep 2009, 1:44 PM

Posting Permissions

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