Announcement Announcement Module
No announcement yet.
Binding entities to your view Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding entities to your view

    Hi guys,

    We've been binding entities directly to our views quite successfully using the different PropertyEditors. We are now running into 2 situations which seem to mandate the use of an intermediary form object:

    1. Using 2 selects (one for hours, one for minutes) to bind to a single minutesAfterMidnight property.
    2. Adding / deleting objects of a list, where the list is sorted alphabetically.

    It would be possible to implement these 2 solutions by modifying the domain entity to fit the UI, but I would like to avoid this. I am also aware that Parent.getChildren() could actually return a sorted list, but I'd like to avoid implementing Parent.getChildrenSortedByName(), Parent.getChildrenSortedByDate(), etc., to suit the needs of the different views.

    Are there any Editors that allow mapping 2 form properties to a single object property? Is there a way to sort a list before displaying it using a form:select tag? Or are we stuck using a form object, which will contain all the properties and validation constraints of the entity and be capable of updating the underlying entity?

    We're using Spring 3.0.x with JSP as the view technology.

    Thanks a bunch!
    Last edited by spiff; Oct 6th, 2010, 06:38 PM. Reason: Clarified

  • #2
    Turns out that rather simple solutions to both problems had eluded us.

    1. We used a hidden field to contain the actual value, and JavaScript to convert to and from the combo boxes.
    2. We implemented a simple JSP custom tag that takes var, items and comparatorClass parameters.

    Hope that helps someone eventually.