List of usage examples for org.springframework.ui ModelMap addAllAttributes
public ModelMap addAllAttributes(@Nullable Map<String, ?> attributes)
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/orgprofile", method = RequestMethod.POST) public String saveOrganisation(@Valid @ModelAttribute("organisation") Organisation organisation, @RequestParam(required = false) boolean userpage, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("emps", employeeService.getAll()); return "admin/orgprofile"; }// w w w.ja v a2 s . com organisationService.update(organisation); return userpage ? "redirect:/organisation?id=" + organisation.getId() : "redirect:/admin/organisations"; }
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/shopprofile", method = RequestMethod.POST) public String saveShop(@Valid @ModelAttribute("shop") Shop shop, @RequestParam(required = false) boolean userpage, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("emps", employeeService.getAll()); model.addAttribute("orgs", organisationService.getAll()); return "admin/shopprofile"; }//w w w . ja va 2 s . com shopService.update(shop); return userpage ? "redirect:/shop?id=" + shop.getId() : "redirect:/admin/shops"; }
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/addoffice", method = RequestMethod.POST) public String addOffice(@Valid @ModelAttribute("addOfficeFrm") Office office, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("emps", employeeService.getAll()); model.addAttribute("orgs", organisationService.getAll()); return "admin/addoffice"; }/*from ww w .java 2s . c o m*/ officeService.create(office); return "redirect:/admin/offices"; }
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/officeprofile", method = RequestMethod.POST) public String saveOffice(@Valid @ModelAttribute("office") Office office, @RequestParam(required = false) boolean userpage, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("emps", employeeService.getAll()); model.addAttribute("orgs", organisationService.getAll()); return "admin/officeprofile"; }//from w w w.j a v a 2 s . co m officeService.update(office); return userpage ? "redirect:/office?id=" + office.getId() : "redirect:/admin/offices"; }
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/addorganisation", method = RequestMethod.POST) public String addOrganisation(@Valid @ModelAttribute("addOrganisationFrm") Organisation organisation, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("emps", employeeService.getAll()); return "admin/addorganisation"; }/*from w w w.j a v a 2 s .c o m*/ organisationService.create(organisation); return "redirect:/admin/organisations"; }
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/addshop", method = RequestMethod.POST) public String addShop(@Valid @ModelAttribute("addShopFrm") Shop shop, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("emps", employeeService.getAll()); model.addAttribute("orgs", organisationService.getAll()); return "admin/addshop"; }/*w w w . j a v a 2s. com*/ shopService.create(shop); return "redirect:/admin/shops"; }
From source file:ru.codemine.ccms.router.AdminRouter.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "/admin/profile", method = RequestMethod.POST) public String saveEmployee(@Valid @ModelAttribute("employee") Employee employee, @RequestParam(required = false) boolean userpage, BindingResult result, ModelMap model) { if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("rolesList", employeeService.getAllRoles()); return "admin/profile"; }//from ww w . j a v a2s .com if (employee.getPassword().isEmpty()) { Employee oldEmp = employeeService.getById(employee.getId()); employee.setPassword(oldEmp.getPassword()); employeeService.evict(oldEmp); } else { BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(11); employee.setPassword(passwordEncoder.encode(employee.getPassword())); } employeeService.update(employee); return userpage ? "redirect:/employee?id=" + employee.getId() : "redirect:/admin/employees"; }
From source file:ru.codemine.ccms.router.TaskRouter.java
@Secured("ROLE_USER") @RequestMapping(value = "/tasks/addcomment", method = RequestMethod.POST) public String addTaskComment(@RequestParam("taskid") Integer taskid, @Valid @ModelAttribute(value = "newcomment") Comment comment, BindingResult result, ModelMap model) { Task task = taskService.getById(taskid); if (result.hasErrors()) { model.addAllAttributes(utils.prepareModel()); model.addAttribute("openTasksCount", taskService.getOpenTaskCount()); model.addAttribute("task", task); model.addAttribute("newcomment", comment); return "pages/tasks/taskinfo"; }//from w w w .j ava2s . c om comment.setCreator(employeeService.getCurrentUser()); task.getComments().add(comment); taskService.update(task); taskService.sendMsgOnAddComment(task, comment); return "redirect:/tasks/taskinfo?id=" + task.getId(); }
From source file:ru.codemine.ccms.router.TaskRouter.java
@Secured("ROLE_OFFICE") @RequestMapping(value = "/reports/tasks", method = RequestMethod.GET) public String tasksReport(ModelMap model, @RequestParam(required = false) String dateStartStr, @RequestParam(required = false) String dateEndStr) { model.addAllAttributes(utils.prepareModel()); DateTimeFormatter formatter = DateTimeFormat.forPattern("dd.MM.YYYY"); LocalDate dateStart = dateStartStr == null ? LocalDate.now().withDayOfMonth(1) : formatter.parseLocalDate(dateStartStr); LocalDate dateEnd = dateEndStr == null ? LocalDate.now().dayOfMonth().withMaximumValue() : formatter.parseLocalDate(dateEndStr); if (dateEnd.isBefore(dateStart)) dateEnd = dateStart;//from www. j a v a2 s.co m model.addAttribute("dateStartStr", dateStart.toString("dd.MM.YYYY")); model.addAttribute("dateEndStr", dateEnd.toString("dd.MM.YYYY")); return "reports/tasks-byuser"; }
From source file:ru.codemine.ccms.router.ExpencesRouter.java
@Secured("ROLE_OFFICE") @RequestMapping(value = "/reports/expences", method = RequestMethod.GET) public String getExpencesReportPage(ModelMap model, @RequestParam(required = false) String dateYear) { if (dateYear == null) dateYear = LocalDate.now().toString("YYYY"); model.addAllAttributes(utils.prepareModel()); model.addAttribute("selectedYear", dateYear); model.addAttribute("yearList", utils.getYearStrings()); return "/reports/expences"; }