Hi Guys,
I am using spring mvc and recently i had conversation with my colleague.
Some of my Jsp's uses conbo box. Values for this combo box are populate using form tag of spring.
ModelAttribute stores object that is used by spring to render other values of form.
So I populate the list which is used to render combo box in a object which is used as modelAttribute and place that object in ModelAttribute and return it.
I was told by my colleague that its poor OO Design since this list is required only for display i should populate it separtely in ModelMap rather thann the POJO
eg:
say i need to show state.jsp then in my stateController i have
In above eg this entityObject is the object which contains list of states and some data which is used for rendering the jspCode:public String getState(ModelMap map){ map.addAttribute("State",entityObject); }
my colleague says it should be
Please let me know what is right design so that i can take corresponding decisionCode:public String getState(ModelMap map){ map.addAttribute("State",entityObject); map.addAttribute("stateList",listOfStates); }
Thanks and Regards
Patil Abhijeet


Reply With Quote