Hi, all, I have the problem to populate collection from Struts 2 Action. I followed the previous post from: http://www.nabble.com/Populating-collection-in-struts-2-Action-properties-td8784718.html#a8784718
But it still does not work, I post my method here, any help will be appreciated. In my domain model: public class Timesheet extends BaseObject { @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "timesheet") private Set<Workday> workdays = new HashSet<Workday>(); ....... } public class Workday extends BaseObject { @ManyToOne @JoinColumn(name = "timesheetId", updatable = false, insertable = false) private Timesheet timesheet; ...... } The JSP: <s:textfield name="timesheet.startDate" theme="simple" id="timesheet.startDate" cssClass="text medium" /> <s:iterator value="%{new int[14]}" status="stat"> <s:textfield theme="simple" id="%{'timesheet.workdays['+#stat.index+'].date'}" name="%{'timesheet.workdays['+#stat.index+'].date'}" disabled="true" size="10" maxlength="10"/> </s:iterator> ....................... the generated html: <input id="timesheet.workdays[5].date" type="text" disabled="disabled" value="" maxlength="10" size="10" name="timesheet.workdays[5].date"/> The TimesheetAction: public class TimesheetAction extends BaseAction { private static final long serialVersionUID = 3449265559398237913L; private TimesheetManager timesheetManager; private List<Timesheet> timesheets; private Timesheet timesheet; private Long id; public void setId(Long id) { this.id = id; } public Timesheet getTimesheet() { return timesheet; } public void setTimesheet(Timesheet timesheet) { this.timesheet = timesheet; } public List<Timesheet> getTimesheets() { return timesheets; } public void setTimesheets(List<Timesheet> timesheets) { this.timesheets = timesheets; } public void setTimesheetManager(TimesheetManager timesheetManager) { this.timesheetManager = timesheetManager; } public String delete() { timesheetManager.remove(timesheet.getId()); saveMessage("job deleted"); return SUCCESS; } public String edit() { if (id != null) { timesheet = timesheetManager.get(id); } else { timesheet = new Timesheet(); } return SUCCESS; } public String save() throws Exception { if (cancel != null) { return "cancel"; } if (delete != null) { return delete(); } SecurityContext securityContext = SecurityContextHolder.getContext(); User user = (User) securityContext.getAuthentication().getPrincipal(); System.out.println(timesheet.getStartDate()); System.out.println(timesheet.getJobId()); System.out.println(timesheet.getApprover().getId()); System.out.println("--------" + timesheet.getWorkdays().size()); System.out.println("--------" + user); timesheet.setSubmitter(user); timesheet.setApprover(user.getSupervisor()); timesheet.setSubmitDate(DateUtil.getToday().getTime()); timesheet.setStatus("1"); boolean isNew = (timesheet.getId() == null); timesheet = timesheetManager.save(timesheet); String key = (isNew) ? "timesheet added" : "timesheet updated"; saveMessage(key); if (!isNew) { return INPUT; } else { return SUCCESS; } } public String list() { timesheets = timesheetManager.getAll(); return SUCCESS; } } Since annotation is used in the domain class, I think the properties file is not necessary. But I still provide one, placed in the same folder with Timesheet.class. Timesheet-conversion.properties: CreateIfNull_workdays=true Element_workdays=com.absorbx.ctm.model.Workday In my Action, the size of workdays is 0, you can see from my log file: 1 -2 --------0 [EMAIL PROTECTED],enabled=true,accountExpired=false,credentialsExpired=false,accountLocked=false,Granted Authorities: ,ROLE_USER] Sorry for the mess code, is there any step I missed? Best regards, Ke CAI -- View this message in context: http://www.nabble.com/Problem-with-Populating-collection-in-struts-2-Action-tp14661680p14661680.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]