1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    27
    Vote Rating
    -1
    Answers
    1
    hebr3 is an unknown quantity at this point

      0  

    Default Answered: How to change url in jsonp proxy?

    Answered: How to change url in jsonp proxy?


    I define a jsonp proxy to read data out of iTunes, the url is
    http://itunes.apple.com/search?entity=album&term=... (... is the search string)
    It works for a given search string.

    How can I set the url dynamically. I tried to use the beforeload event with store.setProxy, but I do not manage to replace the url in the network call.
    Is there an automatic way of passing parameters to the store/proxy so that the proxy handles the url extension?

    Best regards
    hebr3

  2. Have you tried using the setUrl method on the proxy?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    Answers
    3102
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      1  

    Default


    Have you tried using the setUrl method on the proxy?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  4. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    27
    Vote Rating
    -1
    Answers
    1
    hebr3 is an unknown quantity at this point

      0  

    Default


    I don't find the setUrl-method, does it really exist?

    I did now
    Code:
    ...
        var p=this.getProxy().getInitialConfig();
        p.url = 'http://itunes.apple.com/search?entity=album&attribute=allArtistTerm&term='+searchValue;
        this.setProxy(p);
    ...

  5. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    827
    Vote Rating
    55
    Answers
    84
    jerome76 has a spectacular aura about jerome76 has a spectacular aura about jerome76 has a spectacular aura about

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Have you tried using the setUrl method on the proxy?
    I've searched the docs and haven't found a method named setUrl for proxies (or getUrl for the matter). If one does exist that'd be great.

  6. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    Answers
    3102
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    All properties in the config object in all classes get a setter and getter created. If you look at Ext.data.proxy.Server url is in the config object so it has a setUrl and getUrl method created for it. Ajax and JsonP proxy extends Server proxy, in buildRequest (where the url is used) it executes the getUrl which simply returns the _url propery that the setUrl will change so it should always update to use the new url.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  7. #6
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    827
    Vote Rating
    55
    Answers
    84
    jerome76 has a spectacular aura about jerome76 has a spectacular aura about jerome76 has a spectacular aura about

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    All properties in the config object in all classes get a setter and getter created. If you look at Ext.data.proxy.Server url is in the config object so it has a setUrl and getUrl method created for it. Ajax and JsonP proxy extends Server proxy, in buildRequest (where the url is used) it executes the getUrl which simply returns the _url propery that the setUrl will change so it should always update to use the new url.
    I understand assuming config options have mutators and accessors; I'm just saying that if there were documentation included for those getters and setters, and a majority does, then some questions like these could be prevented, at least for those users who turn to the docs before the forum.

  8. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    4
    Vote Rating
    0
    1984 is on a distinguished road

      0  

    Default


    I was having the same problem and after few hours of try and errors and found a solution:

    //get the store
    var store =Ext.getStore('myLittleStore');

    //get the store proxy
    var proxy=store .getProxy();

    //change the url
    proxy.setUrl('new url go here');

    //re-load the store with new data
    store .load();