Announcement Announcement Module
Collapse
No announcement yet.
Workflow: How to show form and results at the same time? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Workflow: How to show form and results at the same time?

    I've been looking at the Controller hierarchy for days, trying to figure
    out how to retain the query form onscreen while also displaying the
    results of that query.

    Which controller has the workflow to do this and HOW can it
    be implemented?

    I think I want a workflow that does the following
    1) receive GET request,
    2) populate form with initial request parameters
    3) populate form with data retrieved from other sources
    4) form displayed, user fills in form
    5) user submits form
    6) form is re-displayed (with users selection state!) followed by
    results from processing the form
    7) user can change and resubmit form over and over again (i.e.
    user can loop back to step 4 as much as they want). Each time the
    current state of the form is displayed, followed by the results
    from the last query.

    This looks like it MUST be possible in the Spring paradigm but
    I just can't figure out how.

    Should I just breakdown and create TWO simple controllers which
    just pass data to each other in the session or is there an easy
    "spring way"?

    Any help appreciated,
    -tom

  • #2
    The way I would do this is just have one controller; have the same view for form & success; in the onSubmit() of your controller add the 'results' object(s) to your model.
    In the view, test for the existence of the results object(s), e.g. in jsp,
    Code:
    <c&#58;if test=$&#123;!empty myObject&#125;>
      display the results
    <c&#58;if/>
    If you initialise your model with errors.getModel(), you'll have the formbacking object which will populate the form with the users selection.

    HTH

    Comment


    • #3
      Thanks for thinking about this with me Chris! It really
      helped me to proceed in the right direction.

      Your suggestion seems so obvious (in 20-20 hindsight!) that I was
      chagrined that I hadn't tried it. I think it works but there
      are a couple of wrinkles to get it to do so. One has to
      set the 'sessionForm' and 'bindOnNewForm' AND apparently
      one has to store important information in the session and
      reload it back into the model to really make things work.

      Thanks to your suggestion, I actually discovered that,
      for my particular application, I was the victim of another
      complicating problem. I am using 'displayTag', a fabulous
      library for formatting tabular information. 'displayTag' allows
      you to sort the tables by column after they are displayed.
      Unfortunately, the sort does a GET back to the server which,
      in my workflow paradigm, wipes out the results.

      My solution was to create a custom controller based on
      AbstractCommandController which implements a sortof
      "three way" post: 1) original GET, 2) refresh GET and 3) a POST.
      This solved my problem.

      Thanks again for your help,
      -tom

      Comment


      • #4
        What I've done in the past to deal with displaytag is override isFormSubmission() to check if the request has any parameters that start with 'd-', which displaytag parameters do. If so, handle the request as a normal form submit.

        Comment


        • #5
          Great suggestion, thanks.

          I hope that others who are using displayTag will see your post
          because displayTag is doing a lot of useful work with very little
          effort on my part. Thanks again,
          -tom

          Comment


          • #6
            It did help a lot - I was trying to use displaytag, and the hint about isFormSubmission saved the day - the week actually.

            Thanks guys!

            Originally posted by Tom Hicks
            Great suggestion, thanks.

            I hope that others who are using displayTag will see your post
            because displayTag is doing a lot of useful work with very little
            effort on my part. Thanks again,
            -tom

            Comment


            • #7
              Sorting problem with displaytag and Webflow

              Originally posted by dhewitt View Post
              What I've done in the past to deal with displaytag is override isFormSubmission() to check if the request has any parameters that start with 'd-', which displaytag parameters do. If so, handle the request as a normal form submit.

              Hi,

              The displaytag solutions are particular SpringMVC related, is there also a solution for Webflow?

              Problem description:
              step 1) Delete a row from the webpage results in a webflow action that deletes eventually a record from the backend and refreshes the webpage accordingly.

              step 2) Then, try to sort a column from the same webpage using displaytag. Sorting results in the previous delete action in Webflow instead of refreshing the webpage.

              So when sorting, the delete webflow action is repeated again, instead of just sorting the column and refreshing the webpage.

              Do you have any suggestions to solve this problem?

              Regards,

              Ali Yuksel

              Comment

              Working...
              X