OK, I'm real close here. Using that FAQ link - which was VERY helpful, thanks! - I was able to get my checklist utility working. However, I have one minor quirk. The first time I ran it, all checkboxes were empty/false. Which was expected. I then went down and selectively checked a few records and they all set properly. Nice. However, UNchecking those checkboxes does not set the boolean back to false. When I step through the debugger, I see the iteration's row is showing TRUE for those checkboxes. My thought was that it was seeing null and I might need to explicity check for null and if so, set to false - but I cannot see a null coming in. All I see is true. My code is very closesly modeled after what's found in that FAQ page, so I won't paste it all here. Any thoughts on what I might need to add?
Here is my iteration on the JSP:
<logic:iterate id="employeeForm" name="checklistItemForm" property="employeeList">
<html:hidden name="employeeForm" property="employeeID" indexed="true" />
<tr>
<td><bean:write name="employeeForm" property="lastName" />,
<bean:write name="employeeForm" property="firstName" /></td>
<td><bean:write name="employeeForm" property="crdNumber" /></td>
<td><html:checkbox name="employeeForm" property="check1" indexed="true" /></td>
<td><html:checkbox name="employeeForm" property="check2" indexed="true" /></td>
<td><html:checkbox name="employeeForm" property="check3" indexed="true" /></td>
</tr>
</logic:iterate>
here is checklistItemForm.getEmployeeForm:
public EmployeeForm getEmployeeForm(int index)
{
// make sure that orderList is not null
if(this.employeeList == null)
{
this.employeeList = new ArrayList();
}
// indexes do not come in order, populate empty spots
while(index >= this.employeeList.size())
{
this.employeeList.add(new EmployeeForm());
}
// return the requested item
return (EmployeeForm) employeeList.get(index);
}
Here is the relevant portion of the action called upon save/submit:
List employeeList = checklistForm.getEmployeeList();
try {
IEmployeeManager employeeManager = (IEmployeeManager)getServiceLocator().getEmployeeManager();
//employeeManager.updateChecklistValues(employeeList);
for(Iterator employeeIter = employeeList.iterator(); employeeIter.hasNext() ;)
{
EmployeeForm employeeRow = (EmployeeForm) employeeIter.next();
String empIDkey = employeeRow.getEmployeeID();
EmployeeImpl employee = (EmployeeImpl)employeeManager.findEmployeeByID(empIDkey);
if(employee != null)
{
employee.setCheck1(employeeRow.isCheck1());
employee.setCheck2(employeeRow.isCheck2());
employee.setCheck3(employeeRow.isCheck3());
employeeManager.saveEmployee(employee);
failed = false;
}
}
}
The red text is where I'm scratching my head. It works going false to true but I can't UNcheck the boxes to get back to false.
Help? thanks!