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
    Nov 2011
    Posts
    52
    Answers
    2
    Vote Rating
    1
    testvogel is on a distinguished road

      0  

    Default Unanswered: Sending form values json encoded to REST java webservice

    Unanswered: Sending form values json encoded to REST java webservice


    Hi all,

    I'm new to Sencha Touch and want to build a simple form panel which will be send to a REST service which is implement with Java jersey. The webservice is working properly (tested with Soap UI) and also the sencha app is working fine until I'll press the submit button of the form and if I'm using the submit() function. If I use Ajax in the button handler, the webservice will be called properly, otherwise I get following exception at the webservice:

    Code:
    Caused by: java.lang.Error: Error: could not match input    at 
    com.sun.jersey.json.impl.reader.JsonLexer.zzScanError(JsonLexer.java:491)
        at com.sun.jersey.json.impl.reader.JsonLexer.yylex(JsonLexer.java:736)
    Sencha code:

    Code:
    { 
                               text: 'Save',
                                ui: 'confirm',
                                handler: function() {
                                    console.log('storing');
                                    var form = Ext.getCmp('checkoutform');
                                    console.log(Ext.JSON.encode(form.getValues()));
                                    form.submit({
                                            url: 'http://localhost:8080/example/service/',
                                            method:'POST', 
                                            headers: {
                                                'Content-Type': 'application/json'
                                            },
                                            params: Ext.JSON.encode(form.getValues()),                                    
                                            success:function(form, result){
                                                   console.log("succ");
                                             },
                                              failure:function(form, result){
                                                console.log("fail");
                                            }
                                    });
                                }
                            }
    If i use the following code the call of the webservice is working fine:

    Code:
    {
                                text: 'Save',
                                ui: 'confirm',
                                handler: function() {
                                    console.log('storing');
                                    var form = Ext.getCmp('checkoutform');
                                    console.log(Ext.JSON.encode(form.getValues()));
                                    Ext.Ajax.request({
                                            url: 'http://localhost:8080/example/service/',
                                            method:'POST', 
                                            headers: {
                                                'Content-Type': 'application/json'
                                            },
                                            params: Ext.JSON.encode(form.getValues()),
                                    })
                                }
                            }
    Does anyone have an idea why the form.submit function is sending anything but not properly json data?
    btw. form.getValues() returns json data:

    Code:
    {"name":"","address":""}

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,519
    Answers
    3447
    Vote Rating
    813
    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


    The submit method is going to use form POST and encode the params using Ext.urlDecode.

    If you need a more specialized way of submitting, you can use Ext.Ajax.request to do the submitting. In fact, jsonData will automatically encode the Object to JSON.
    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.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    52
    Answers
    2
    Vote Rating
    1
    testvogel is on a distinguished road

      0  

    Default


    Hi,

    I thought that

    Code:
    headers: {'Content-Type': 'application/json' }, 
     params: Ext.JSON.encode(form.getValues()),
    would encode the url encoded form data to json encoded data.

    Is it possible to change the encoding format of the form data or do I have to use Ext.Ajax.request instead?

Thread Participants: 1