Home Spring Spring3.2 The checkboxes tag
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

The checkboxes tag

Advertisement
In this section, you will learn about checkboxes tag of Spring form tag library.

The checkboxes tag

In this section, you will learn about checkboxes tag of Spring form tag library.

The checkboxs tag of Spring form tag library provides multiple input tag of  type checkbox.

Consider a scenario where you need to create check boxes for category selection from list of categories. One way to implement this is to provide list of all the possible hobbies with checkbox tag of Form tag library.

But sometimes you not prefer to list all the possible categories in your JSP page. In spite of that you can provide a list of the available options at runtime and pass that in to the tag.

In the below code, categoryList, available as a model attribute, contains the list of available categories :

<form:form>
	<table>
		<tr>
			<td>Interests:</td>
			<td>
				<%-- Property is of an array or of type java.util.Collection --%>
				<form:checkboxes path="preferences.category" items="${categoryList}"/>
			</td>
		</tr>
	</table>
</form:form>

 

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 22, 2013

Ask Questions?    Discuss: The checkboxes tag  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com