1. #1
    Sencha User
    Join Date
    Jun 2008
    Posts
    17
    Vote Rating
    0
    rynam0 is on a distinguished road

      0  

    Default Answered: FormPanel submit JSON

    Answered: FormPanel submit JSON


    Hello,

    I am wondering if there is a way to configure a FormPanel's submit() to send a content-type other than application/x-www-form-urlencoded. I know ExtJs allows you to change the type of submission the forms make, but can we somehow set a FormPanel to submit a Content-Type of application/json and change the default accept header as well?

    Thanks in advance!
    -Ryan

  2. We have nothing implement this for. You could could subclass FormPanel and change the behaviour. Basicly you would create the json string on your on, put it into a hidden field and submit only that one.

  3. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Answers
    60
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    We have nothing implement this for. You could could subclass FormPanel and change the behaviour. Basicly you would create the json string on your on, put it into a hidden field and submit only that one.

  4. #3
    Sencha User
    Join Date
    Jun 2008
    Posts
    17
    Vote Rating
    0
    rynam0 is on a distinguished road

      0  

    Default


    Thanks, Sven:

    I was hoping for the equivalent functionality offered by ExtJs forms. I think I may try out your suggestion.

    Thanks again,
    -Ryan

  5. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    I'm fairly certain that even ExtJS only supports that functionality when doing a AJAX post, not a standard form post. Html forms only have a few formats they support, and JSON is not one of them.

    To make a custom AJAX call, the GWT class RequestBuilder is used.

    Take the model bound to your form, pass it through JsonConverter.encode to get a JSONObject, and call toString() on that to get the json data. This can be sent to the server in any way you choose, including via RequestBuilder. HttpProxy can be instructed to use this: Override HttpProxy.generateUrl to serialize to JSON as described above, and make sure the standard RequestBuilder given is told to use POST as the method.

  6. #5
    Sencha User
    Join Date
    Jun 2008
    Posts
    17
    Vote Rating
    0
    rynam0 is on a distinguished road

      0  

    Default


    Yes, you are correct about ExtJs AJAX posts but the feature I was speaking to was the ability to pass the jsonData config. Anyway, I did almost exactly as you suggested with RequestBuilder except I extended FormPanel and overrode submit utilizing RequestBuilder. This is an acceptable solution as I get the benefits of FormPanel mixed with REST calls.

    Thanks for your input once again!

  7. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Answers
    60
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    If you are not using a normal form submit, you should not use a FormPanel at all, as this one adds an extra overhead which you not require in that case.

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar