PDA

View Full Version : Scope of the command object if I jump between JSP's


bedag
Nov 24th, 2004, 05:49 AM
Hi!

I'm writing a web app similar to the petclinic. As with petclinic, I can find, add and edit users. Additionally I can find, add and edit pets as well (same classes/jsp's as the user flow).

Now if I add or edit a user, I would assign an existing pet (only one) to the user, but differential to the petclinic, I don't want to add (and therefore create) a new pet, instead I want to add an existing one, i.e. I want to jump to the findPets page, find a pet and assign this pet (with a button on the pet detail page) to the user. After clicking on this button, the add or edit user page should appear again (and the already entered user information should still be there).

I cannot use an AbstractWizardFormController because the flow could change, i.e. on the findPets page it should be possible to find an existing one or to create a new one, both going afterwards to the pet detail page with the "assign button" on it.

I think I have to save the user command object as well as the pet command object into the session (instead of the request), so that they could being reused after returning from the pet detail page to the user add or edit page. So I've tried to use the sessionForm property as well as the setSessionForm(true) method, but it doesn't work. I'm not sure on which subclasses of the SimpleFormController I must set this property exactly.

Could anyone help me please?

Regards,
bedag

klr8
Nov 25th, 2004, 02:40 PM
This kind of stuff can be done with the Spring web flow controller (http://www.ervacon.com/products/springwebflow). You could model your application with a user-flow and a pet-flow and have the user-flow call the pet-flow as a sub flow to find a pet to assign. When the pet-flow returns you map the selected pet into the user-flow model.

Read http://www.ervacon.com/products/springwebflow/article for details on how to use this controller.

Erwin