Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    5
    Vote Rating
    1
    senchite01 is on a distinguished road

      0  

    Default Answered: Dynamic Assignment of Extra Parameters in REST Proxy

    Answered: Dynamic Assignment of Extra Parameters in REST Proxy


    We are building an app using PhoneGap + Sencha 2.x. The app will allow potentially multiple users to login and logout while the app is running. As part of the server API we've built, we assign a session id to the app. Pretty plain stuff.

    In order to get the session id to our API for authentication, since PhoneGap does not handle cookies, we need to send extra parameters to our API. Thus far we've been doing this via a custom proxy writer we've developed. Now we want to transition to using Sencha Architect, which can't handle custom writers. How then can we update the model and store definitions with a new session id assigned by the server (when a new user logs in) so that future requests will send the correct session id?

    I have one idea, but it would require us modifying our copy of the Sencha code. We could assign a function as a value within the extraParams object of the proxy. The code modification would be where Sencha comiles the extra parameters for the proxy. Adding a foreach loop that would check for callbacks to build dynamic values would be the solution. Is this overkill or does Sencha already offer a solution to meet our needs?

    Thank you,

    Todd

  2. Correct. In the store, here it the applyProxy that sets the proxy on the store, notice in red:

    Code:
        applyProxy: function(proxy, currentProxy) {
            proxy = Ext.factory(proxy, Ext.data.Proxy, currentProxy, 'proxy');
    
            if (!proxy && this.getModel()) {
                proxy = this.getModel().getProxy();
            }
    
            if (!proxy) {
                proxy = new Ext.data.proxy.Memory({
                    model: this.getModel()
                });
            }
    
            if (proxy.isMemoryProxy) {
                this.setSyncRemovedRecords(false);
            }
    
            return proxy;
        },

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,519
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You could just have a beforeload event listener on the store to set the extra param to have your session data.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 User
    Join Date
    May 2012
    Posts
    5
    Vote Rating
    1
    senchite01 is on a distinguished road

      0  

    Default


    Thank you for your response. I can see in loading a store how that would work, but when making changes to models persistent via a REST call, one would need to use the save() method on a model. This would mean that the model's proxy would be used, and any extraParams would be from the initial load/define or autoload of the Model definition That is, unless, one were to set the extraParams argument on a model's proxy before every save operation performed on model, since there are no events on models as is the case with stores. That would be an error prone methodology, as developers would sometimes forget to modify the proxy values.

    I fall back to my original plan of attack -- to modify the processing of the extraParams to allow a value to be a function which will be called to dynamically set the values at runtime. Again, unless there is some other methodology that I am not yet aware of.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,519
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    If you set the proxy on the model and not on the store, the store will use the proxy from the model therefore sharing the same proxy instance.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  6. #5
    Sencha User
    Join Date
    May 2012
    Posts
    5
    Vote Rating
    1
    senchite01 is on a distinguished road

      0  

    Default


    To make sure that your communication is effective, meaning that I understand what you meant -- By setting the proxy on the model, when a store loads the model instances through a REST request, updating the extraParams via an onbeforeload event will change the params in the model proxy definitions. Therefore, when the save() method is called for an individual model, the extraParams will have been updated already, and the correct sessionId (the extra parameter we care about) will be available for the request.

    Again, I thank you for your responses.

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,519
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Correct. In the store, here it the applyProxy that sets the proxy on the store, notice in red:

    Code:
        applyProxy: function(proxy, currentProxy) {
            proxy = Ext.factory(proxy, Ext.data.Proxy, currentProxy, 'proxy');
    
            if (!proxy && this.getModel()) {
                proxy = this.getModel().getProxy();
            }
    
            if (!proxy) {
                proxy = new Ext.data.proxy.Memory({
                    model: this.getModel()
                });
            }
    
            if (proxy.isMemoryProxy) {
                this.setSyncRemovedRecords(false);
            }
    
            return proxy;
        },
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

Thread Participants: 1

Tags for this Thread