This duplicates another bug already reported in our system: DSGNR-1789
  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    1
    Vote Rating
    1
    irochusv is on a distinguished road

      1  

    Default Config object for api property in Proxy, stores as string & not as object literal

    Config object for api property in Proxy, stores as string & not as object literal


    Sencha Architect 2.0.0 build 412

    Problem:
    The api property on the Ajax Proxy serves to specify specific urls on CRUD action methods. Set through the property panel in Sencha Architect build 412, the object literal is interpreted and being incoporated in the generated code as a string. Which is invalid and leads Ext to ignore the api property & use the proxy url instead.

    Test:
    Introduce an object literal in Sencha Architect like

    { create: '/rest/usercreate.json',
    read: '/rest/users.json'',
    update : '/rest/userupdate.json',
    destroy : '/rest/users.json'
    }

    Watch the underlying code and see how its being defined as the string:

    '{ create: \'/rest/usercreate.json\',\n read: \'/rest/users.json\'\',\n update : \'/rest/userupdate.json\',\n destroy : \'/rest/users.json\'\n}'

    Create, Update & Destroy actions are being ignored (the read is the default proxy url)
    The fix is to manually edit the file, after which the API urls are being used correctly. This fix is not permanent as further editing of the Proxy will overwrite the customisation and restore the invalid string.

    Solution:
    To correctly incorporate the API object literal as aforementioned literal and not a string literal

  2. #2
    Ext JS Premium Member
    Join Date
    Jan 2009
    Posts
    3
    Vote Rating
    0
    sforbes is on a distinguished road

      0  

    Default I came to report this one myself

    I came to report this one myself


    Now I'm a little worried that it's still not fixed after all this time

  3. #3
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,306
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    So Architect is attempting to protect you when you put in an invalid string. If you look at the above first post you'll notice that there is an extra stray ' at the end of read. This is why it was converted into a string.

    Sencha Architect 2.2 will provide you additional feedback letting you know that it was unable to create an object. It will also allow you to put in random JS expressions of your own liking via a feature called processConfig for Ext JS or writing it in the initialize method of a Touch component.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  4. #4
    Ext JS Premium Member
    Join Date
    Jan 2009
    Posts
    3
    Vote Rating
    0
    sforbes is on a distinguished road

      0  

    Default


    I guess it also doesn't like objects like the following:

    {
    create : Admin.wsurl('mapengine/create'),
    read : Admin.wsurl('mapengine/read'),
    update : Admin.wsurl('mapengine/update'),
    destroy : Admin.wsurl('mapengine/delete')
    }

    I though I'd be able to get around the 'url' property having to be a string, but it sounds like processConfig will be what I'm after.

  5. #5
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,306
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Nope, there is no way it can resolve it and determine what it is (therefore it says oh lets convert it to a string).

    processConfig will enable you to process that particular component and then do osmething like

    Code:
    processMyProxy: function(config) {
        config.api = {
           create : Admin.wsurl('mapengine/create'),
           read : Admin.wsurl('mapengine/read'),
           update : Admin.wsurl('mapengine/update'),
           destroy : Admin.wsurl('mapengine/delete')
       };
       return config;
    }
    In the interim (Architect lower than 2.2) you can do this via an override of your store.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  6. #6
    Ext JS Premium Member
    Join Date
    Jan 2009
    Posts
    3
    Vote Rating
    0
    sforbes is on a distinguished road

      0  

    Default


    Thanks for the explanation.

    I like the idea of an override for the store, that suggestion sounds like the perfect way to update the url parameter in all of them in one location.

  7. #7
    Sencha Premium Member
    Join Date
    Apr 2010
    Posts
    193
    Vote Rating
    24
    elgs will become famous soon enough

      0  

    Default


    I have exactly the same problem. I think Sencha is doing some implicit guess under the hood, such "protection" is really unnecessary and indeed annoying.

    @aconran, my project got stuck because of this. Can you please give us a quick fix for this problem, or give us a workable preview of 2.2?

    Thanks!

  8. #8
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,306
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Prior to 2.2, you will have to implement something like this via an override.

    Architect will convert any object to a string which it cannot resolve.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

Thread Participants: 3