List of usage examples for org.springframework.web.servlet.mvc.support RedirectAttributes getFlashAttributes
Map<String, ?> getFlashAttributes();
From source file:org.wallride.web.controller.guest.user.PasswordResetController.java
@RequestMapping(value = "/{token}", method = RequestMethod.PUT) public String reset(@PathVariable String token, @Validated @ModelAttribute(FORM_MODEL_KEY) PasswordResetForm form, BindingResult errors, BlogLanguage blogLanguage, RedirectAttributes redirectAttributes) { redirectAttributes.addFlashAttribute(FORM_MODEL_KEY, form); redirectAttributes.addFlashAttribute(ERRORS_MODEL_KEY, errors); PasswordResetToken passwordResetToken = userService.getPasswordResetToken(token); if (passwordResetToken == null) { redirectAttributes.addFlashAttribute(INVALID_PASSOWRD_RESET_LINK_ATTR_NAME, true); return "redirect:/password-reset"; }/*from w w w . j av a 2 s . c o m*/ LocalDateTime now = LocalDateTime.now(); if (now.isAfter(passwordResetToken.getExpiredAt())) { redirectAttributes.addFlashAttribute(INVALID_PASSOWRD_RESET_LINK_ATTR_NAME, true); return "redirect:/password-reset"; } if (!errors.hasFieldErrors("newPassword")) { if (!ObjectUtils.nullSafeEquals(form.getNewPassword(), form.getNewPasswordRetype())) { errors.rejectValue("newPasswordRetype", "MatchRetype"); } } if (errors.hasFieldErrors("newPassword*")) { return "redirect:/password-reset/{token}"; } PasswordUpdateRequest request = new PasswordUpdateRequest().withUserId(passwordResetToken.getUser().getId()) .withPassword(form.getNewPassword()).withLanguage(blogLanguage.getLanguage()); userService.updatePassword(request, passwordResetToken); redirectAttributes.getFlashAttributes().clear(); return "redirect:/login"; }
From source file:org.fenixedu.ulisboa.specifications.ui.registrationsdgesexport.RegistrationDGESStateBeanController.java
@RequestMapping(value = _SEARCH_URI) public String search(@RequestParam(required = false) ExecutionYear executionYear, @RequestParam(required = false) Integer phase, @RequestParam(required = false) CandidacySituationType candidacySituationType, @RequestParam(required = false) IngressionType ingressType, @RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate, @RequestParam(required = false) Boolean exportStatistics, Model model, RedirectAttributes redirectAttributes) { Map<String, ?> flashAttributes = redirectAttributes.getFlashAttributes(); if (flashAttributes.get("executionYear") != null) { executionYear = (ExecutionYear) flashAttributes.get("executionYear"); }/*from ww w .j a v a2s .c om*/ if (flashAttributes.get("phase") != null) { phase = (Integer) flashAttributes.get("phase"); } if (flashAttributes.get("candidacySituationType") != null) { candidacySituationType = (CandidacySituationType) flashAttributes.get("candidacySituationType"); } if (flashAttributes.get("ingressType") != null) { ingressType = (IngressionType) flashAttributes.get("ingressType"); } if (flashAttributes.get("beginDate") != null) { beginDate = (String) flashAttributes.get("beginDate"); } if (flashAttributes.get("endDate") != null) { endDate = (String) flashAttributes.get("endDate"); } if (flashAttributes.get("exportStatistics") != null) { exportStatistics = (Boolean) flashAttributes.get("exportStatistics"); } LocalDate bd = null; LocalDate ed = null; if (StringUtils.isNotBlank(beginDate)) { bd = DateTimeFormat.forPattern("yyyy-MM-dd").parseLocalDate(beginDate); } if (StringUtils.isNotBlank(endDate)) { ed = DateTimeFormat.forPattern("yyyy-MM-dd").parseLocalDate(endDate); } List<RegistrationDGESStateBean> searchregistrationdgesstatebeanResultsDataSet = filterSearchRegistrationDGESStateBean( executionYear, phase, candidacySituationType, ingressType, bd, ed); model.addAttribute("searchregistrationdgesstatebeanResultsDataSet", searchregistrationdgesstatebeanResultsDataSet); model.addAttribute("executionYears", getExecutionYearDataSource()); model.addAttribute("phases", getPhases()); model.addAttribute("candidacyStates", getCandidacySituationTypeDataSource()); model.addAttribute("ingressTypes", getIngressTypeDataSource()); CandidacyToProcessBean bean = new CandidacyToProcessBean(); model.addAttribute("objectBean", bean); model.addAttribute("objectBeanJson", getBeanJson(bean)); model.addAttribute("selectedExecutionYear", executionYear); model.addAttribute("selectedPhase", phase); model.addAttribute("selectedCandidacyState", candidacySituationType); model.addAttribute("selectedIngressType", ingressType); model.addAttribute("exportStatistics", exportStatistics); return "registrationsdgesexport/search"; }