Announcement Announcement Module
Collapse
No announcement yet.
Proper binding design pattern for complex objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Proper binding design pattern for complex objects

    I'm new to the Spring MVC framework and have a question regarding the preferred way of binding complex objects and the use of PropertyEditor. I have the following domain object that I wish to bind to a JSP search page (Note that I have eliminated accessor methods in the interest of brevity):

    Code:
    public class SearchCriteria {
    	private String searchText;
    	private Country country;
    	private Set<Metro> metros;
    &#125;
    Now, I realize in this example I could just replace the country field with a long representing the country ID and do the same with the metros property, but there are some other cases where binding directly to the domain model would be extremely desireable.

    From what I have researched, the preferred way to do this would be using custom PropertyEditors for the country and metros fields. However, I have been unable to turn up a satisfactory example of a custom PropertyEditor integrated into Spring MVC. Could someone point me towards a proper example or show me how to bind to a JSP the domain object I have cited? I am planning on using a dropdown for country and a multi-selection list for metros.

    Thanks!

  • #2
    the preferred way of binding complex objects and the use of PropertyEditor
    You can only do this if that complex object can be entirely represented as a (submitted) string - and then converted to the complex object. I guess if it's a drop down list you can control this.

    From what I have researched, the preferred way to do this would be using custom PropertyEditors for the country and metros fields
    For complex data that already exists, you generally use a key to look them up as you have said.

    Comment

    Working...
    X