Trying to pass the list of selected subjects to Controller, but the bean is not receiving the list of subjects.
Here's the code that I'm trying:
$("#submitCreateStudent").click(function() {
var selSubjectIds = new Array();
$('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function() {
if (selSubjectIds.length < 1) {
selSubjectIds.push($(this).attr('data-record-key') + '$');
} else {
selSubjectIds += $(this).attr('data-record-key') + '$';
}
});
if (validateCreateStudentForm()) {
var data = new FormData();
data.append('firstName', $("#firstNameInCreateStudent").val());
data.append('lastName', $("#lastNameInCreateStudent").val());
data.append('address', $("#studentAddressInCreateStudent").val());
data.append('collegeName', $("#studentCollegeNameInCreateStudent").val());
data.append('phoneNumber', $("#phoneNumberInCreateStudent").val());
data.append('email', $("#emailInCreateStudent").val());
data.append('studentDepartment', $("#departmentInCreateStudent").val());
data.append('studentBranch', $("#branchInCreateStudent").val());
data.append('DateOfBirth', $("#dobInCreateStudent").val());
data.append('DateOfReport', $("#dorInCreateStudent").val());
data.append('loginUserName', $("#studentUserNameInCreateStudent").val());
data.append('loginPassword', $("#passwordInCreateStudent").val());
data.append('studentSubjects', selSubjectIds);
// data.append('skipInitialTraining', skipInitialTraining);
$("#maskingId").mask("Saving...");
$.ajax({
url: "AddStudent.do",
data: data,
//
//Remaining code goes here.
});
});
All the details are coming to controller class except for the list of subjects which are selected check boxes.