1. #1
    Touch Premium Member lylepratt's Avatar
    Join Date
    Dec 2010
    Location
    Austin, Texas
    Posts
    159
    Vote Rating
    0
    lylepratt is on a distinguished road

      0  

    Default Override buildUrl in a RestProxy in Sencha Architect

    Override buildUrl in a RestProxy in Sencha Architect


    I'm having a hard time overriding the 'buildUrl(request)' function on a RestProxy in Sencha Architect. Does anyone know how to do this?

    Thanks,
    Lyle
    Twitter: lylepratt

  2. #2
    Touch Premium Member lylepratt's Avatar
    Join Date
    Dec 2010
    Location
    Austin, Texas
    Posts
    159
    Vote Rating
    0
    lylepratt is on a distinguished road

      0  

    Default Solved...Sort of

    Solved...Sort of


    Here's my solution. I don't like that you have to override a Model, to do this small a change to the buildUrl function on the proxy, but I couldn't get it to work any other way. Also, another quirk is that it fails if you return a value in the modified buildUrl function, but if you just don't return anything, it still seems to work correctly.

    Code:
    Ext.define('BV.model.override.CallModel', {
        requires: 'BV.model.CallModel'
    }, function() {
        Ext.override(BV.model.CallModel, {
            constructor: function() {
                this.callOverridden(arguments);
                var newProxy = this.getProxy();
                newProxy.buildUrl = function(request) {
                    var me        = this,
                        operation = request.getOperation(),
                        records   = operation.getRecords() || [],
                        record    = records[0],
                        model     = me.getModel(),
                        idProperty= model.getIdProperty(),
                        format    = me.getFormat(),
                        url       = me.getUrl(request),
                        params    = request.getParams() || {},
                        id        = (record && !record.phantom) ? record.getId() : params[idProperty];
            
                    if (me.getAppendId() && id) {
                        if (!url.match(/\/$/)) {
                            url += '/';
                        }
                        url += id;
                        delete params[idProperty];
                    }
            
                    if (format) {
                        if (!url.match(/\.$/)) {
                            url += '.';
                        }
            
                        url += format;
                    }
            
                    request.setUrl(url+"/");
            
                    //return me.callParent([request]);
                }
                this.setProxy(newProxy);
            }
        });
    });
    Twitter: lylepratt

  3. #3
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,273
    Vote Rating
    81
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    Do you need to override for ALL proxies or just for one mode/store?

    If is for ALL proxies, write your override code outside SA but include it in your html page after extjs.

    Of course you have to use your own html page and not "app.html".

    Regards,
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  4. #4
    Touch Premium Member lylepratt's Avatar
    Join Date
    Dec 2010
    Location
    Austin, Texas
    Posts
    159
    Vote Rating
    0
    lylepratt is on a distinguished road

      0  

    Default


    There are a lot of things I can do Outside of SA, but I want to do it INSIDE of SA. If the way I did it is the only way possible, then I would consider it a bug.
    Twitter: lylepratt

  5. #5
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,273
    Vote Rating
    81
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    Quote Originally Posted by lylepratt View Post
    There are a lot of things I can do Outside of SA, but I want to do it INSIDE of SA. If the way I did it is the only way possible, then I would consider it a bug.
    So instead of doing things the simple way when you need NOT STANDARD BEHAVIOUR you prefer to do the hard way?

    SA is just another tool, use for what is good (UI design and application gluing) and use your "other tools" (editors, ant scripts, manual coding) for what is not good.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  6. #6
    Touch Premium Member lylepratt's Avatar
    Join Date
    Dec 2010
    Location
    Austin, Texas
    Posts
    159
    Vote Rating
    0
    lylepratt is on a distinguished road

      0  

    Default


    There tons of features in Sencha Architect that override "standard behavior". This is one example where something that is commonly overridden is not easy to override is Sencha Architect. I took the time to post an alternative for the community, and I hope that the Sencha team will make this easier in the future.

    In my previous response I was simply pointing out that I asked specifically about how to "Override buildUrl in a RestProxy in Sencha Architect". However, I do appreciate your attempt to help.
    Twitter: lylepratt

  7. #7
    Sencha User
    Join Date
    Oct 2013
    Posts
    3
    Vote Rating
    0
    aleklados is on a distinguished road

      0  

    Default buildUrl override in Architect.

    buildUrl override in Architect.


    Hi Lyle,

    I realize it is pretty late answer but I was looking for something related and found your post still unanswered so I guess I can help you or others that will navigate here with same problem

    Answer:
    All you have to do to create your custom url for REST Proxy in Architect is to go to said Proxy, and in Config Panel add a function called buildUrl and put request as its parameter. Afterwards this function will appear on Proxy with little annotation that you're overriding a parent function or config.

    proxy_buildUrl.png
    Attached Images

Thread Participants: 2