PDA

View Full Version : 2 Forms 2 SimpleFormController's


rrpspring
Feb 9th, 2006, 01:26 PM
Hi, i'm trying to set a search form, controlled by a SimpleFormController Class, getting several search criteria, submitting them to a second form where, in the formBackingObject, i want to retrieve those criteria and do the query to pre-populate the second form...how should i do this?

Colin Yates
Feb 9th, 2006, 02:05 PM
Not entirely sure I get you :)

Are you saying:

- request 1 starts
- renders search form
- request 1 ends

user enters search criteria and clicks submit

- request 2 starts
- search executes based on search criteria (and returns 4 objects)
- another form is rendered based on the 4 objects
- request 2 ends

NOW WHAT?

Based on the above, you might want to look at AbstractWizardFormController, or if it is more complex; Spring Web Flow

rrpspring
Feb 9th, 2006, 02:17 PM
Not entirely sure I get you :)

Are you saying:

- request 1 starts
- renders search form
- request 1 ends

user enters search criteria and clicks submit

- request 2 starts
- search executes based on search criteria (and returns 4 objects)
- another form is rendered based on the 4 objects
- request 2 ends

NOW WHAT?

Based on the above, you might want to look at AbstractWizardFormController, or if it is more complex; Spring Web Flow

Ok, let me be more concise:

i have a form1 (on a JSP) attached to a SFC (sfc1). Here i get the values for the search criteria (4 fields). I submit it (adding the search criteria object to the model) to another sfc2 with a form2 attached (where i want to show my results), and, previously to showing form2, i want to pre-populate it. To do this i want to call formBackingObject on sfc2, get the search done and bind the results to form2's fields...

My problem:
in sfc2 formBackingObject i can't find a way to extract my search criteria object using request.getParameter(myObject) - myObject is a HashMap with the different search attributes...I can only find a way to extract simple (like string) parameters

Any idea how i can do this?
TIA

Colin Yates
Feb 9th, 2006, 03:56 PM
First off; yes, if you store the first formBackingObject to the session (set sessionForm=true) and give a sensible name then in the second SFC you can just retrieve it from the session.

I am not clear why you are splitting this over two forms? Surely it would be better to have a single SFC which is responsible for executing the search and showing the result?

What do you gain from having a second SFC, or put it another way; why use a SFC for the first controller, which as far as I can tell is doing absolutely nothing :)