Results 1 to 10 of 22

Thread: Processing forms in webscript which is part of page

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Posts
    8

    Default Processing forms in webscript which is part of page

    Hi all,

    I created a RESTful service (webscript) with a form on it. It processes GET (responds with a form) and POST (shows the result) at the moment. It works fine till I add that webscript to a page that contains other webscript components like header and footer. Once I submit the form I get exceptions that neither header nor footer supports the method POST.

    Please could someone advise what is the proper way to process forms? I don't want to include the whole page into the webscript respond because it goes against the main idea of surf (as I understand it) – arranging multiple components on one page.

    Thanks!

  2. #2

    Default

    You have two options, in the trunk we have added a feature so that all components fall back to the .get implementation if no .post implementation is found -this is ideal for POSTing to pages where you only want to add specific .post logic for some components - so update to trunk codeline will fix it for you. The other option is to add .post implementations for all the components on the page you are POSTing too - this is obviously annoying as it is a copy/paste exercise - but if you don't want to update to trunk that is your option currently.

    Cheers,

    Kev

  3. #3
    Join Date
    Jun 2010
    Location
    Reading
    Posts
    8

    Default

    If you do take the duplicate post file route then you can import the get js and freemarker files into the post files to avoid duplicating the file contents.

  4. #4
    Join Date
    Sep 2010
    Posts
    8

    Default

    Thanks a lot for the quick response.

    The behavior to fall back to the .get implementation for all the components that doesn't have .post is exactly what I would expect. Thanks for adding that feature!

  5. #5
    Join Date
    Sep 2010
    Posts
    8

    Default

    Tested. Everything works fine except... post parameters aren't reachable as
    args["paramName"]

  6. #6

    Default

    I assume you are talking about the .post implementation webscript? As you wouldn't expect POST params from a FORM to be available to .get webscript impls. Also if you are submitting a FORM then the data should be available in the "formdata" model object.

    Cheers,

    Kev

Posting Permissions

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