I have a module where I have to update attendance of each student. The code is as below:
public void updateDailyAttendance(ActionRequest areq, ActionResponse aRes) throws Exception{
int totalEmployees = EmployeeLocalServiceUtil.getEmployeesCount();
String attendanceValue = getAttendanceValue(areq);
//long attPKey = CounterLocalServiceUtil.increment(Employee.class.getName());
for (int i = 0; i < totalEmployees; i++) {
// use attendanceValue to update employee entry
//String attendanceValue = getAttendanceValue(areq);
// parameterValue is value of radio button parameter
long attPKey = CounterLocalServiceUtil.increment(Employee.class.getName());
Attendance newAttendanceInstance = new AttendanceImpl();
newAttendanceInstance.setAttId(attPKey);
newAttendanceInstance.setAttStatus(attendanceValue);
AttendanceLocalServiceUtil.addAttendance(newAttendanceInstance);
} }
private String getAttendanceValue(ActionRequest areq) {
Enumeration parameters = areq.getParameterNames();
while (parameters.hasMoreElements()) {
String parameterName = parameters.nextElement().toString();
if (parameterName.startsWith("updateattendance")) {
return areq.getParameter(parameterName);
}
}
throw new IllegalStateException("Parameter updateattendance cannot be found!!");
}
When I use the above code my database gets updated but the attendance (present/absent entered for first employee is taken as the value for other employees even though I mark different values(Present/absent) for other employees
How should I modify the above code so that the radio button value entred for each employee is stored ?