I am using Spring 3.1.0.RELEASE. I have this field in my command object ...
public Set<EventFeed> getUserEventFeeds() { return this.userEventFeeds; }
On my Spring JSP page, I want to show a list of all possible event feeds, and then check the boxes if the user has one of his sets. I want some special HTML formatting around each checkbox, so I'm trying ...
<form:form method="Post" action="eventfeeds.jsp" commandName="user"> ... <c:forEach var="eventFeed" items="${eventFeeds}"> <tr> <td><form:checkbox path="userEventFeeds" value="${eventFeed}"/></td> <td>${eventFeed.title}</td> </tr> </c:forEach> ...
However, items are not checked by default if they are in a set. How can I do it? Here is the binding I use in my controller class ...
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(EventFeed.class, new EventFeedEditor()); } private class EventFeedEditor extends PropertyEditorSupport { @Override public void setAsText(String text) throws IllegalArgumentException { setValue(eventFeedsDao.findById(Integer.valueOf(text))); } @Override public String getAsText() { return ((EventFeed) getValue()).getId().toString(); } }
Dave
source share