java - Value entered for one entry is stored for other entries instead of unique values -
i have module have update attendance of each student. code 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()); (int = 0; < totalemployees; i++) { // use attendancevalue update employee entry //string attendancevalue = getattendancevalue(areq); // parametervalue 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 found!!"); }
when use above code database gets updated attendance (present/absent entered first employee taken value other employees though mark different values(present/absent) other employees
how should modify above code radio button value entred each employee stored ?
you attendancevalue
once before loop. getattendancevalue
returns 1 string, how can attendancevalue
can different between 2 students?
string attendancevalue = getattendancevalue(areq);
that's why attendancevalue
s same. need updating value every employee inside loop.
Comments
Post a Comment