Results 1 to 6 of 6

Thread: FormPanel submit JSON

  1. #1
    Sencha User
    Join Date
    Jun 2008
    Posts
    17
    Vote Rating
    0
      0  

    Default 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
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      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
      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 User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109
    Vote Rating
    93
      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
      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
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      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.

Posting Permissions

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