View Full Version : Which Controller?
ranger
Mar 15th, 2006, 03:34 PM
I would like to make a little web-based database-application, using the Spring JDBC and MVC.
The start page would be a logon page, then a list of the databases, then the tables from the selected database... I tried the SimpleFormController, but I had problems with the <sping:bind> on the second page to get back the name of the selected database to a class.
Which (and how many) contoller should I use? One per page, or one controller for more pages? And is the spring:bind jsp tag the applicable method to get back informations from the jsp page?
(Sorry, I beginner in MVC, but the tutorials were not definite for me).
Thanks very much!
kenevel
Mar 15th, 2006, 05:16 PM
Hi Ranger,
Have a look at my example in this post (http://forum.springframework.org/showthread.php?t=23225) which may help you understand how the bind tag works.
The number of different controllers you need depends entirely on how many different pages you need to create. I guess there would be one controller that knows how to provide the reference data to show how many databases there are, a second controller that knows how to retrieve the table names from a specified database and so on. The alternative is to use the MultiActionController which can handle several different scenarios in one concrete class.
As this sounds like it's going to be a point-and-click series of pages, my preference would be to subclass AbstractController and make each controller a separate class. Just my preference there - it's difficult to go any further than that based on what you've said.
HTH
Mike
andrews
Mar 15th, 2006, 05:52 PM
... I had problems with the <sping:bind> ... It should of course be <spring:bind> (with an "r"). Is this a typo in your code or just in your forum post?
Colin Yates
Mar 15th, 2006, 05:54 PM
I agree with Mike (hey, isn't that a quote from a film????)
Anyways, I would also map each page onto it's own controller.
A funky alternative is to map these controllers onto REST style URLs, i.e.:
/yourapp/tables/TABLE_NAME/columns/YOUR_COL, or even:
/yourapp/TABLE_NAME/YOUR_COL
Just a thought :)
ranger
Mar 16th, 2006, 05:15 AM
andrews:
It should of course be <spring:bind> (with an "r"). Is this a typo in your code or just in your forum post?
It is just in my forum post :D, sorry.
kenevel:
Have a look at my example in this post which may help you understand how the bind tag works.
<string:bind path="employeeForm.employee.name">
I think this is <spring:bind>, but I don't understand, why is path="employeeForm.employee.name", and not path="employeeForm.employee.firstName" or "employeeForm.employee.surname" ?:confused:
Thanks for your advices
kenevel
Mar 16th, 2006, 09:19 AM
You're quite right... well spotted. Deliberate error to see if you were paying attention ;)
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.