Spring MVC managing multiple views with single controller
- by Sudhir
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?