In my table, I've a row with checkbox which tells the controller whether that particular row of the table has to be included or no. The check box does not have relation with other rows. I tried adding it in the following way :
<form:form id="fee" method="post" modelAttribute="clientForm" commandName = "clientForm"
action="<%= request.getContextPath().toString()%>/addFee.do">
<TABLE>
<tr>
<c:forEach var="type" items="${clientInfo}" varStatus="status">
<td><form:checkbox class="editable${ifeeCount}" path="includeFeeValue" value="false"/> </td>
<td>feeType<c:out value = "${status.index}"/></td>
<td>Source Fee<c:out value = "${status.index}"/></td>
<td><form:input class="editable${ifeeCount}" disabled="true" path="overriddenFee" /></td>
<td><form:errors path="overriddenFee" cssClass="error" /></td>
</c:forEach>
</tr>
</TABLE>
And in my form, I've a list private ArrayList<String> includeFeeValue;
And i'm trying to retrieve this in the spring controller class as follows :
@RequestMapping(value="/addFee.do",method = RequestMethod.POST)
protected @ResponseBody ModelAndView selectValues(@ModelAttribute("clientForm") PaswFeeMaintenanceForm MyMaintForm ) throws Exception {
for(int i=0;i<MyMaintForm.getIncludeFeeValue().size();i++){
System.out.println("Checkbox : "+MyMaintForm.getIncludeFeeValue().get(i)+ " of "+i);
}
}
Once I submit my form, it throws null pointer exception in here : MyMaintForm.getIncludeFeeValue().size() .
Could you tell me what's missing here?
getIncludeFeeValue()is returningnullgetIncludeFeeValue()isnullfor sure, maybedisabled="true"is not binding the value, try removing this and test again.