PDA

View Full Version : Update Save delete in One Controller


Rama
Jul 13th, 2007, 01:54 AM
I have a controller for update/saving the data of a form into database

1) On submit for (saving command object)/( update in association with formbacking object) the form data into the table
2) Formbacking Object for rending the data which was there in the database
on the screen.

Can we handle the delete in the same controller or do we need to write the different controller?

jglynn
Jul 15th, 2007, 11:29 AM
Delete can be dealt with in the same controller.

Rama
Jul 16th, 2007, 12:33 AM
Can you please elaborate?

noon
Jul 16th, 2007, 02:05 AM
Use multiActionController. By its parameter value Spring decides the method to be run in the controller.

saif_uddin
Jul 16th, 2007, 02:20 AM
Delete can be dealt with in the same controller. (but not be considered as a good approach. this line would definitely help you to find your answer "If you don't have a form, you don't need a FormController. This is a major difference to Struts" (Reference Chapter 12. Web framework (http://static.springframework.org/spring/docs/1.1.5/reference/mvc.html)
hope it helps.

jglynn
Jul 16th, 2007, 11:05 PM
Not be good approach? Why?

If he has an SFC which already accommodates create/update it makes perfect sense to accommodate deletes as well.

That's the great thing about Spring, if he'd rather use a MAC for deletes he can go that route as well.

saif_uddin
Jul 17th, 2007, 03:25 AM
Not be good approach? Why?

I would say SFC is not suggested to use in a absence of form. (a web page without form tag)


If he has an SFC which already accommodates create/update it makes perfect sense to accommodate deletes as well.

because both create/update normally have a form tag, but not sure about the delete whether she using a form or not?

That's the great thing about Spring, if he'd rather use a MAC for deletes he can go that route as well.

agreed