List of usage examples for org.springframework.web.servlet.support RequestContextUtils getOutputFlashMap
public static FlashMap getOutputFlashMap(HttpServletRequest request)
From source file:de.iteratec.iteraplan.presentation.dialog.GuiController.java
/** * Store all error messages from the complete redirect-chain into the request-scope attribute 'MVC_ERROR_MESSAGES_KEY'. * Must be called at least once, most suitable at the very end of {@link Theme} controller's method(s). * Can be called several times without harm. * //from w w w .j av a2s . c o m * Use in JSP like this: ${requestScope['iteraplanMvcErrorMessages']} * * Concerning the usage of FlashMap/-Attributes, please refer to comment in * "springmvc-servlet.xml", bean "DefaultAnnotationHandlerMapping". * * @param request The {@link HttpServletRequest} */ @SuppressWarnings("unchecked") protected void storeErrorMessagesInRequestScope(HttpServletRequest request) { List<String> errorMessages = Lists.newArrayList(); // Add error messages from previous requests of the redirect-chain Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request); if (inputFlashMap != null && inputFlashMap.containsKey(SessionConstants.MVC_ERROR_MESSAGES_KEY)) { errorMessages.addAll((List<String>) inputFlashMap.get(SessionConstants.MVC_ERROR_MESSAGES_KEY)); } // Add error messages from the current (and last!) request of the redirect-chain FlashMap outputFlashMap = RequestContextUtils.getOutputFlashMap(request); if (outputFlashMap.containsKey(SessionConstants.MVC_ERROR_MESSAGES_KEY)) { errorMessages.addAll((List<String>) outputFlashMap.get(SessionConstants.MVC_ERROR_MESSAGES_KEY)); } // Use same key for request attribute like for FlashMap key. ImmutableList<String> unqiueErrorMessages = ImmutableSortedSet.copyOf(errorMessages).asList(); request.setAttribute(SessionConstants.MVC_ERROR_MESSAGES_KEY, unqiueErrorMessages); }
From source file:com.epam.cme.storefront.controllers.pages.AbstractRegisterPageController.java
protected String processRegisterCmeUserRequest(final String referer, final RegisterForm form, final BindingResult bindingResult, final Model model, final HttpServletRequest request, final HttpServletResponse response) throws CMSItemNotFoundException { if (bindingResult.hasErrors()) { model.addAttribute(new LoginForm()); GlobalMessages.addErrorMessage(model, "form.global.error"); return handleRegistrationError(model); }// w w w .ja v a 2 s . c o m final CmeRegisterData data = new CmeRegisterData(); data.setFirstName(form.getFirstName()); data.setLastName(form.getLastName()); data.setOrganizationsIds(form.getOrganizations()); data.setLogin(form.getEmail()); data.setPassword(form.getPwd()); data.setTitleCode(form.getTitleCode()); try { getBlockableCustomerFacade().register(data); getAutoLoginStrategy().login(form.getEmail(), form.getPwd(), request, response); getSubscriptionFacade().updateProfile(new HashMap<String, String>()); RequestContextUtils.getOutputFlashMap(request).put(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("registration.confirmation.message.title")); } catch (final DuplicateUidException e) { LOG.warn("registration failed: " + e); model.addAttribute(new LoginForm()); bindingResult.rejectValue("email", "registration.error.account.exists.title"); GlobalMessages.addErrorMessage(model, "form.global.error"); return handleRegistrationError(model); } catch (final SubscriptionFacadeException e) { LOG.warn(String.format("Creating new subscription billing profile for user %s failed", form.getEmail()), e); model.addAttribute(new LoginForm()); GlobalMessages.addErrorMessage(model, "registration.error.subscription.billing.profil"); return handleRegistrationError(model); } return REDIRECT_PREFIX + getSuccessRedirect(request, response); }
From source file:org.kmnet.com.fw.web.exception.SystemExceptionResolver.java
/** * Sets result message// w ww .ja v a 2 s .c om * <p> * Sets result message in {@code HttpServletRequest}({@code FlashMap}) * </p> * @param ex Exception * @param request {@link HttpServletRequest} */ protected void setResultMessages(Exception ex, HttpServletRequest request) { if (!StringUtils.hasText(resultMessagesAttribute)) { return; } if (!(ex instanceof ResultMessagesNotificationException)) { return; } ResultMessages resultMessages = ((ResultMessagesNotificationException) ex).getResultMessages(); request.setAttribute(resultMessagesAttribute, resultMessages); FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request); if (flashMap != null) { flashMap.put(resultMessagesAttribute, resultMessages); } }
From source file:com.poscoict.license.web.controller.ManagementController.java
@RequestMapping(value = { "modifyProgressInfo" }, method = RequestMethod.POST) public String modifyProgressInfo(@RequestParam(value = "objectId") String objectId, @RequestParam(value = "P_USER_NAME") String userName, @RequestParam(value = "P_PROJECT_NAME") String projectName, @RequestParam(value = "P_USER_ADDRESS", required = false) String userAddress, @RequestParam(value = "P_MANAGER_NAME", required = false) String managerName, @RequestParam(value = "P_MANAGER_OFFICE_PHON", required = false) String officePhon, @RequestParam(value = "P_MANAGER_CEL_PHON", required = false) String celPhon, @RequestParam(value = "P_MANAGER_EMAIL", required = false) String email, @RequestParam(value = "P_USER_START_DATE", required = false) String startDate, @RequestParam(value = "P_PRODUCT_FILE_ID", required = false) String product, HttpServletRequest request, HttpSession session) {//www. j ava 2 s . c o m getManagementService.modifyProgressInfo(objectId, userName, projectName, userAddress, managerName, officePhon, celPhon, email, startDate, product, (String) session.getAttribute("USER_NO")); FlashMap map = RequestContextUtils.getOutputFlashMap(request); map.put("objectId", objectId); return "redirect:/progressUserInfom"; }
From source file:com.poscoict.license.web.controller.ManagementController.java
@RequestMapping(value = { "insertComment" }, method = RequestMethod.POST) public String insertComment(String objectId, String comment, HttpSession session, HttpServletRequest request) throws UserException { System.out.println("___________comment " + objectId); getManagementService.insertComment(objectId, comment, (String) session.getAttribute("USER_NO")); FlashMap map = RequestContextUtils.getOutputFlashMap(request); map.put("objectId", objectId); return "redirect:/progressUserInfom"; }
From source file:com.poscoict.license.web.controller.ManagementController.java
@RequestMapping(value = { "deleteComment" }, method = RequestMethod.POST) public String deleteComment(String objectId, String commentNo, HttpSession session, HttpServletRequest request) throws UserException { getManagementService.deleteComment(objectId, commentNo, (String) session.getAttribute("USER_NO")); FlashMap map = RequestContextUtils.getOutputFlashMap(request); map.put("objectId", objectId); return "redirect:/progressUserInfom"; }
From source file:com.poscoict.license.web.controller.ManagementController.java
@RequestMapping(value = { "modifyComment" }, method = RequestMethod.POST) public String modifyComment(String objectId, String commentNo, String comment, HttpSession session, HttpServletRequest request) throws UserException { getManagementService.modifyComment(objectId, commentNo, comment, (String) session.getAttribute("USER_NO")); FlashMap map = RequestContextUtils.getOutputFlashMap(request); map.put("objectId", objectId); return "redirect:/progressUserInfom"; }
From source file:com.poscoict.license.web.controller.ManagementController.java
@RequestMapping(value = { "changeUserStatus" }, method = RequestMethod.POST) public String changeUserStatus(String objectId, String uStatus, HttpSession session, HttpServletRequest request) throws UserException { getManagementService.changeUserStatus(objectId, uStatus, (String) session.getAttribute("USER_NO")); FlashMap map = RequestContextUtils.getOutputFlashMap(request); map.put("objectId", objectId); return "redirect:/progressUserInfom"; }
From source file:com.epam.cme.storefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/add-address", method = RequestMethod.POST) public String addAddress(@Valid final AddressForm addressForm, final BindingResult bindingResult, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { if (bindingResult.hasErrors()) { GlobalMessages.addErrorMessage(model, "form.global.error"); storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); model.addAttribute("countryData", checkoutFacade.getDeliveryCountries()); model.addAttribute("titleData", userFacade.getTitles()); return ControllerConstants.Views.Pages.Account.AccountEditAddressPage; }/*from w w w . ja va 2 s . c o m*/ final AddressData newAddress = new AddressData(); newAddress.setTitleCode(addressForm.getTitleCode()); newAddress.setFirstName(addressForm.getFirstName()); newAddress.setLastName(addressForm.getLastName()); newAddress.setLine1(addressForm.getLine1()); newAddress.setLine2(addressForm.getLine2()); newAddress.setTown(addressForm.getTownCity()); newAddress.setPostalCode(addressForm.getPostcode()); newAddress.setBillingAddress(false); newAddress.setShippingAddress(true); final CountryData countryData = new CountryData(); countryData.setIsocode(addressForm.getCountryIso()); newAddress.setCountry(countryData); newAddress.setVisibleInAddressBook(addressForm.getSaveInAddressBook().booleanValue()); if (userFacade.isAddressBookEmpty()) { newAddress.setDefaultAddress(true); checkoutFacade.setDeliveryAddress(newAddress); } else { newAddress.setDefaultAddress(addressForm.getDefaultAddress().booleanValue()); } userFacade.addAddress(newAddress); final Map<String, Object> currentFlashScope = RequestContextUtils.getOutputFlashMap(request); currentFlashScope.put(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("account.confirmation.address.added")); return REDIRECT_TO_ADDRESS_BOOK_PAGE; }
From source file:com.daimler.spm.storefront.controllers.pages.QuoteController.java
@ExceptionHandler(IllegalQuoteStateException.class) public String handleIllegalQuoteStateException(final IllegalQuoteStateException exception, final HttpServletRequest request) { final Map<String, Object> currentFlashScope = RequestContextUtils.getOutputFlashMap(request); LOG.warn("Invalid quote state for performed action.", exception); final String statusMessageKey = String.format("text.account.quote.status.display.%s", exception.getQuoteState());// w ww . j av a 2 s. c o m final String actionMessageKey = String.format("text.account.quote.action.display.%s", exception.getQuoteAction()); GlobalMessages.addFlashMessage(currentFlashScope, GlobalMessages.ERROR_MESSAGES_HOLDER, "text.quote.illegal.state.error", new Object[] { getMessageSource().getMessage(actionMessageKey, null, getI18nService().getCurrentLocale()), exception.getQuoteCode(), getMessageSource().getMessage(statusMessageKey, null, getI18nService().getCurrentLocale()) }); return REDIRECT_QUOTE_LIST_URL; }