PDA

View Full Version : Every page a form?


CraigFoote
Jun 5th, 2008, 07:00 PM
I received no response to my previous post so I'll try rephrasing the question. To pass a variable between controllers, does every jsp page require a form? E.g. a user submits a form with some value which populates a command object, passes thru the validator and into a SimpleFormController. This controller gets the command object, gets the entered value and (for lack of anything better to do with it) puts it in the map of a returned Model&View. The new view jsp has the entered value but does it need a form to pass that entered value back to other controllers or can it just have <a href's that map to simple (non-form) Controllers, some of which need that entered value? Is there something the original SimpleFormController can do with the entered value to allow subsequent Controllers to access that entered value, rather than putting it in the Model&View perhaps? Sort of like jsp:useBean I guess is what I'm looking for. I tried defining a bean to hold the entered value in the context.xml but I couldn't figure out a way to reference it in the bean for the SimpleFormController. It expects a commandName and commandClass. Does this make sense? I feel like it's such a simple thing but I'm new to Spring so please correct me if I'm completely off base. :confused:

some one
Jun 5th, 2008, 07:07 PM
you could use the simplest controller .

You will have to implement the Controller interface


That will require you to implement the handleRequest() method.

http://static.springframework.org/spring/docs/2.5.4/api/org/springframework/web/servlet/mvc/Controller.html


~s.

CraigFoote
Jun 5th, 2008, 07:43 PM
Ok I saw this response in a similar post and it works:

SimpleFormController.onSubmit()

request.getSession().setAttribute("userName", ((Login) command).getUserName());
return new ModelAndView(getSuccessView());
I just expected something a little more elegant from Spring. I guess I just overcomplicated things. Thanks for the response!