0

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?

3
  • Possibly getIncludeFeeValue() is returning null Commented Sep 21, 2015 at 8:41
  • 1
    @JaveDeveloper getIncludeFeeValue() is null for sure, maybe disabled="true" is not binding the value, try removing this and test again. Commented Sep 21, 2015 at 8:49
  • I tried after removing diabled=true. It's still the same.Null pointer exception Commented Sep 21, 2015 at 10:29

2 Answers 2

1

Remove disabled='true' and it will work. I faced the same problem with my textfield with property disabled as true.

And also use private String[] includeFeeValue instead of List.

Sign up to request clarification or add additional context in comments.

6 Comments

I tried after removing diabled=true. It's still the same.Null pointer exception
Post your full spring form please.
Updated answer. Can you please use array instead of List and check?
But the checkbox is within the for each loop. I've multiple entries and on click of submit I need the check box values of all the rows.
You can get that in Array as well. Though I'm not sure about it, but it worth a try.
|
0

As your checkbox is disabled, ans disabled elements values never flow to controller or Servlet. I advise you to remove a disabled attribute. I hope so it will work.

1 Comment

I tried after removing diabled=true. It's still the same.Null pointer exception

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.