Results 1 to 7 of 7

Thread: How to change url in jsonp proxy?

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    27
    Answers
    1
    Vote Rating
    2
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      1  

    Default

    Have you tried using the setUrl method on 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.

  4. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    27
    Answers
    1
    Vote Rating
    2
      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
    1,149
    Answers
    132
    Vote Rating
    101
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      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 @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.

  7. #6
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    101
      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
      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();

Posting Permissions

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