Spring MVC managing multiple views with single controller
Posted
by
Sudhir
on Stack Overflow
See other posts from Stack Overflow
or by Sudhir
Published on 2012-09-13T09:36:23Z
Indexed on
2012/09/13
9:38 UTC
Read the original article
Hit count: 151
spring-mvc
I am trying to implement order management module. There are different order types (approximately about 15). Each order has a seperate view. But the actions performed on UI are same irrespective of order type. Below is the structure of my DTO
abstract class Order
abstract class SecurityOrder extends Order
abstract class TermDepositOrder extends Order
..... ..... .....
I am trying to implement a single controller capable of managing all views. Something similar to the one below:
@Controller
public class OrderController<F extends Order> {
public F validate(F order) {
}
public F insert(F order) {
}
}
I am not sure how spring mvc would be able to map request parameters properly to the order instance as it doesn't know which order instance to populate.
Is it possible to achieve this with single controller or should I go with a controller for each order type and duplicate same code across all controllers?
© Stack Overflow or respective owner