List of usage examples for org.springframework.web.servlet.mvc.support RedirectAttributes addAttribute
@Override RedirectAttributes addAttribute(String attributeName, @Nullable Object attributeValue);
From source file:log660.controller.FilmController.java
@RequestMapping(value = "/{idFilm}/rent", method = RequestMethod.POST) public ModelAndView rent(@PathVariable("idFilm") Integer idFilm, RedirectAttributes redirect) { if (userSession.getClient() == null) { redirect.addFlashAttribute("loginRequired", "You must be logged in to rent a copy."); redirect.addAttribute("redirecturl", "/film/" + idFilm); return new ModelAndView("redirect:/auth/login"); }//from www . ja v a 2 s . c o m Client client = userSession.getClient(); try { Copie c = systemDAO.rentCopie(idFilm, client); redirect.addFlashAttribute("rentSuccess", "Succesfully rented copy " + c.getCodeCopie()); } catch (WebFlixValidationException ex) { redirect.addFlashAttribute("rentError", ex.getMessage()); } return new ModelAndView("redirect:/film/" + idFilm); }
From source file:org.wallride.web.controller.admin.user.UserInvitationDeleteController.java
@RequestMapping public String delele(@PathVariable String language, @Valid @ModelAttribute("form") UserInvitationDeleteForm form, BindingResult result, String query, AuthorizedUser authorizedUser, RedirectAttributes redirectAttributes) throws MessagingException { UserInvitation invitation = userService.deleteUserInvitation(form.buildUserInvitationDeleteRequest()); redirectAttributes.addFlashAttribute("deletedInvitation", invitation); redirectAttributes.addAttribute("query", query); return "redirect:/_admin/{language}/users/invitations/index"; }
From source file:controllers.admin.UsersController.java
@PostMapping("/edit/{userId}") public String edit(@Validated(User.UserUpdate.class) @ModelAttribute(ATTRIBUTE_USER_NAME) User user, BindingResult bindingResult, RedirectAttributes redirectAttributes, SessionStatus sessionStatus) { String url = "redirect:/admin/users/edit/{userId}"; logger.info("Usuario a actualizar: " + user.toString()); redirectAttributes.addAttribute("userId", user.getId()); if (bindingResult.hasErrors()) { redirectAttributes.addFlashAttribute(BINDING_RESULT_NAME, bindingResult); return url; }//from w w w. j av a 2s. c o m userService.update(user); sessionStatus.setComplete(); //remove user from session List<String> successMessages = new ArrayList(); successMessages.add( messageSource.getMessage("message.profile.save.success", new Object[] {}, Locale.getDefault())); redirectAttributes.addFlashAttribute("successFlashMessages", successMessages); return url; }
From source file:controllers.CarPropertyController.java
@RequestMapping("/update") public String update(Map<String, Object> model, @RequestParam(value = "groupId", required = false) Long groupId, Long cmgId, @RequestParam("uid") String uid, @RequestParam("paramValue") String paramValue, @RequestParam("percentValue") Long percentValue, @RequestParam("radical") String radical, @RequestParam("cpId") Long cpId, RedirectAttributes ras) throws Exception { carPropertyService.update(cpId, uid, paramValue, percentValue, radical); ras.addFlashAttribute("error", carPropertyService.getResult().getErrors()); ras.addAttribute("groupId", groupId); return "redirect:/CarProperty/show"; }
From source file:controllers.SceneController.java
@RequestMapping(value = "/add") public String addScene(Map<String, Object> model, @ModelAttribute("scene") Scene sceneOne, BindingResult result, HttpServletRequest request, RedirectAttributes ras) throws Exception { sceneService.create(sceneOne);// ww w . j a v a 2s. com ras.addFlashAttribute("error", sceneService.getResult().getErrors()); ras.addAttribute("sceneId", sceneOne.getSceneId()); //model.put("sceneOne", sceneOne); return "redirect:/Scene/show"; }
From source file:cn.edu.zjnu.acm.judge.contest.ContestController.java
@GetMapping("problems/{pid}") public String showProblem(@PathVariable("contestId") long contestId, @PathVariable("pid") long problemNum, RedirectAttributes redirectAttributes) { Problem problem = contestMapper.getProblem(contestId, problemNum); if (problem == null) { throw new EntityNotFoundException(); }/* w w w . j av a 2s . co m*/ redirectAttributes.addAttribute("problem_id", problem.getOrign()); return "redirect:/showproblem"; }
From source file:controllers.SceneController.java
@RequestMapping(value = "/deleteValueRange") public String deleteValueRange(Map<String, Object> model, @RequestParam("valueRangeId") Long valueRangeId, @RequestParam("sceneId") Long sceneId, RedirectAttributes ras) throws Exception { sceneService.deleteValueRange(valueRangeId); ras.addFlashAttribute("error", sceneService.getResult().getErrors()); ras.addAttribute("sceneId", sceneId); //model.put("sceneOne", sceneOne); return "redirect:/Scene/show"; }
From source file:controllers.SceneController.java
@RequestMapping(value = "/addHeap") public String addHeap(Map<String, Object> model, @RequestParam("sceneId") Long sceneId, @RequestParam("heap") String heap, RedirectAttributes ras) throws Exception { sceneService.addValuesFromHeap(sceneId, heap); ras.addFlashAttribute("error", sceneService.getResult().getErrors()); ras.addAttribute("sceneId", sceneId); return "redirect:/Scene/show"; }
From source file:org.wallride.web.controller.admin.user.UserInvitationResendController.java
@RequestMapping public String save(@PathVariable String language, @Valid @ModelAttribute("form") UserInvitationResendForm form, BindingResult result, String query, AuthorizedUser authorizedUser, RedirectAttributes redirectAttributes) throws MessagingException { UserInvitation invitation = userService.inviteAgain(form.buildUserInvitationResendRequest(), result, authorizedUser);// ww w.ja v a 2 s .c o m redirectAttributes.addFlashAttribute("resentInvitation", invitation); redirectAttributes.addAttribute("query", query); return "redirect:/_admin/{language}/users/invitations/index"; }
From source file:com.crazy.pss.common.web.BaseController.java
/** * Flash?/*w w w . j av a 2 s .co m*/ * @param message */ protected void addMessage(RedirectAttributes redirectAttributes, String... messages) { StringBuilder sb = new StringBuilder(); for (String message : messages) { sb.append(message + "<br/>"); } redirectAttributes.addAttribute("message", sb.toString()); redirectAttributes.addFlashAttribute("message", sb.toString()); }