@RequestMapping(value = "editadviseraction", method = RequestMethod.POST) public RedirectView editPost(AdviserAction aa) throws Exception { Integer projectId = aa.getProjectId(); ProjectWrapper pw = this.tempProjectManager.get(projectId); aa.setAdviserName(this.projectDao.getAdviserById(aa.getAdviserId()).getFullName()); if (aa.getId() == null) { aa.setId(random.nextInt()); pw.getAdviserActions().add(aa); } else { for (int i = 0; i < pw.getAdviserActions().size(); i++) { if (pw.getAdviserActions().get(i).getId().equals(aa.getId())) { aa.setAttachments(pw.getAdviserActions().get(i).getAttachments()); pw.getAdviserActions().set(i, aa); } } } this.tempProjectManager.update(projectId, pw); return new RedirectView("editproject?id=" + projectId + "#adviseractions"); }