Announcement Announcement Module
Collapse
No announcement yet.
Trouble making my checkboxes checked Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble making my checkboxes checked

    Hi,

    I'm using Spring 3.1.0.RELEASE. I have this field in my domain object ...

    Code:
    	public Set<EventFeed> getUserEventFeeds() {
    		return this.userEventFeeds;
    	}
    On my Spring JSP page, I want to display a checkbox list of all possible event feeds, and then have checked checkboxes if the user has one in his set. How do I do this? I'm trying this

    Code:
    	<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>
    		...
    The above obviously isn't working. Thanks for your help, - Dave

  • #2
    Use the checkboxes tag... Also you would need a converter/propertyeditor to convert your values.

    Comment


    • #3
      Are you talking about this ...

      Code:
      <form:checkboxes itemValue="value" itemLabel="label"   
        path="user.degrees" items="${degreeLabels }" />
      ? This will render all the checkboxes at once, but I want to insert HTML around each checkbox (like I have in my table example above). So how do I manipulate the above to do that?

      - Dave

      ps - I already have my initBinder, which is in my controller ...

      Code:
      	@InitBinder
      	public void initBinder(WebDataBinder binder) {
      		binder.registerCustomEditor(EventFeed.class, new EventFeedEditor());
      	}

      Comment

      Working...
      X