Spring MVC form checkbox binding

DeployList Model

package com.example.util;

import java.util.List;

public class DeployLists {

	private List<String> deployList;
	public List<String> getDeployList() {
		return deployList;

	public void setDeployList(List<String> deployList) {
		this.deployList = deployList;

ModelAndView DeployLists

	public ModelAndView deployView(){
		ModelAndView mav = new ModelAndView("deploy");
		QueryResult<Map> apexClass = loginService.loginToSalesforce().query("Select Id, Name, ApiVersion, Status from ApexClass");
		List<String> apexClassNames= new ArrayList<String>();
		for (Map className : apexClass.getRecords()){

		mav.addObject("deployList", apexClassNames);
		mav.addObject("deployLists", new DeployLists());
		return mav;


<div class="well clearfix">
	<div class="accordion" id="accordion2">
		<form:form method="POST" commandName="deployLists" action="/login/deploy/result" >
		<div class="accordion-group">
			<div class="accordion-heading">
				<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
			<div id="collapseOne" class="accordion-body collapse in">
				<div class="accordion-inner">
					<form:checkboxes element="li" path="deployList" items="${deployList}"></form:checkboxes></ul>

		<button type="submit" class="btn btn-primary">Deploy</button>


<%@ page language="java" contentType="text/html; charset=US-ASCII"
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<jsp:include page="header.jsp"/>
		<section class="row-fluid" id="why-adminflare">
			<h3 class="box-header"><i class="icon-fire" style="color: #cd522c"></i>Result</h3>
			<div class=" box well ">
				<c:forEach items="${deployLists.deployList}" var="dl" varStatus="index">
<jsp:include page="footer.jsp"/>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: