Results 1 to 3 of 3

Thread: Sorting results using simple form controller

  1. #1
    Join Date
    Jan 2008
    Posts
    11

    Default Sorting results using simple form controller

    I am using a simple form controller to allow users to search for data that gets displayed in the SimpleFormController's success view. I would like to add sorting capability to the search results. For this I created a sort link and I post back to the form where I display the results. However, SimpleFormController forwards the request to the formView instead of calling onsubmit and redisplaying the success view. Any ideas how I can modify this behaviour?

    Thanks

  2. #2

    Default

    When you say you "created a sort link" and that you "post back to the form", I assume this is a regular link (i.e. a GET request) with a querystring representing the sort value?

    If so, it's not seeing it as a submit (and calling onSubmit) because it's not a form POST request. To deal with this, you override isFormSubmission, have it look for the querystring you're using, and return true (thus triggering the call to onSubmit) if it's there.

  3. #3
    Join Date
    Jan 2008
    Posts
    11

    Default

    Quote Originally Posted by jacobmattison View Post
    When you say you "created a sort link" and that you "post back to the form", I assume this is a regular link (i.e. a GET request) with a querystring representing the sort value?

    If so, it's not seeing it as a submit (and calling onSubmit) because it's not a form POST request. To deal with this, you override isFormSubmission, have it look for the querystring you're using, and return true (thus triggering the call to onSubmit) if it's there.
    Thanks for the reply jacob. I was in fact posting to the servlet using javascript on the onclick event on the link. However, the html for the link looked some thing like this:
    <a href="" onclick="postBack()">sort</a>
    what this did was it posted back to the form twice once as a get to the form (because of href="") and once by the javascript post back. I changed the link to
    <a href="#" onclick="postBack()">sort</a>
    so there is only one request sent by the javascript that posts back to the server.

    Your idea is also valid I could examine the request parameters and override isFormSubmission to return true when appropriate. Thanks for your response, it steered me in the right direction.

Posting Permissions

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