Announcement Announcement Module
No announcement yet.
Design pattern for add/update with different validation needs Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Design pattern for add/update with different validation needs

    Hello everyone.

    I am very new to Spring MVC and i'm trying not only to solve what i'm building, but also solve it in a good way. I built a "register new customer"-function for our web site that works perfectly. It has a JSP view, a controller (SubmitCustomerController) and i used a CustomerValidator class where i make sure the customer object has a name, a valid email address, a good password and that the two passwords entered in the view match.

    Fine so far.

    Now i'm building a "change customer information"-function. I figured i'd have a different controller (UpdateCustomerController) but use the same JSP page. I also thought that changing the password would be done in a separate view so i wouldn't show the password fields if the page held an existing customer. This could work but what about the validation then? I'd have to put logic to separate different use cases in the validator class, which doesn't feel like good design.

    So, what is a good design for cases like these? Should i separate the "register new" case totally from the "update existing" case or should i use the same view and controller for both cases?