List of usage examples for org.springframework.web.servlet.mvc.support RedirectAttributes addAttribute
@Override RedirectAttributes addAttribute(String attributeName, @Nullable Object attributeValue);
From source file:me.doshou.admin.maintain.editor.web.controller.OnlineEditorController.java
@RequestMapping(value = "/upload", method = RequestMethod.GET) public String showUploadForm(@RequestParam("parentPath") String parentPath, Model model, RedirectAttributes redirectAttributes) throws UnsupportedEncodingException { String rootPath = sc.getRealPath(ROOT_DIR); parentPath = URLDecoder.decode(parentPath, Constants.ENCODING); File parent = new File(rootPath + File.separator + parentPath); if (!parent.exists()) { redirectAttributes.addFlashAttribute(Constants.ERROR, parentPath + "??"); redirectAttributes.addAttribute("path", ""); return redirectToUrl(viewName("list")); }//from ww w . ja va 2 s . c om model.addAttribute("parentPath", parentPath); return viewName("uploadForm"); }
From source file:es.ucm.fdi.dalgs.group.web.GroupController.java
@RequestMapping(value = "/academicTerm/{academicId}/course/{courseId}/group/add.htm", method = RequestMethod.POST, params = "Undelete") // Every Post have to return redirect public String undeleteGroupAdd(@PathVariable("academicId") Long id_academicTerm, @PathVariable("courseId") Long id_course, @ModelAttribute("addGroup") @Valid Group group, BindingResult resultBinding, RedirectAttributes attr, Locale locale) { if (!resultBinding.hasErrors()) { ResultClass<Group> result = serviceGroup.unDeleteGroup(group, id_course, locale); if (!result.hasErrors()) { attr.addFlashAttribute("group", result.getSingleElement()); return "redirect:/academicTerm/" + id_academicTerm + "/course/" + id_course + "/group/" + result.getSingleElement().getId() + "/modify.htm"; } else {//from ww w . j av a 2 s .c o m if (result.isElementDeleted()) attr.addAttribute("unDelete", true); attr.addAttribute("errors", result.getErrorsList()); } } else { attr.addFlashAttribute("org.springframework.validation.BindingResult.group", resultBinding); } attr.addAttribute("group", group); return "redirect:/academicTerm/" + id_academicTerm + "/course/" + id_course + "/group/add.htm"; }
From source file:controllers.SceneController.java
@RequestMapping("/updateFromXml") public String updateFromXml(Map<String, Object> model, @RequestParam(value = "xlsFile", required = false) MultipartFile file, @RequestParam(value = "sceneId", required = true) Long sceneId, RedirectAttributes ras) { if (file == null || file.isEmpty()) { ras.addFlashAttribute("error", "File not found"); } else {//from w w w . j a v a2 s .c o m File newFile = new File("/usr/local/etc/sceneParamsList"); if (newFile.exists()) { newFile.delete(); } try { FileUtils.writeByteArrayToFile(newFile, file.getBytes()); sceneService.updateFromXml(newFile, sceneId); ras.addFlashAttribute("error", sceneService.getResult().getErrors()); } catch (Exception e) { ras.addFlashAttribute("error", "updateFromXml" + StringAdapter.getStackTraceException(e)/*e.getMessage()*/); } if (newFile.exists()) { newFile.delete(); } } ras.addAttribute("sceneId", sceneId); return "redirect:/Scene/show"; }
From source file:me.doshou.admin.maintain.editor.web.controller.OnlineEditorController.java
@RequestMapping(value = "edit", method = RequestMethod.POST) public String edit(@RequestParam(value = "path") String path, @RequestParam(value = "content") String content, RedirectAttributes redirectAttributes) throws IOException { String rootPath = sc.getRealPath(ROOT_DIR); path = URLDecoder.decode(path, Constants.ENCODING); File file = new File(rootPath + File.separator + path); String parentPath = file.getParentFile().getAbsolutePath().replace(rootPath, ""); FileUtils.write(file, content);//from w w w . j av a2 s. c om redirectAttributes.addFlashAttribute(Constants.MESSAGE, "??"); redirectAttributes.addAttribute("path", parentPath); return redirectToUrl(viewName("list")); }
From source file:controllers.PropertyController.java
@RequestMapping("/updateFromXml") public String updateFromXml(Map<String, Object> model, @RequestParam(value = "propId", required = true) Long propId, @RequestParam(value = "xlsFile", required = false) MultipartFile file, RedirectAttributes ras) throws Exception { if (file == null || file.isEmpty()) { ras.addFlashAttribute("error", "File not found"); } else {/*from ww w . j av a 2 s.com*/ File newFile = new File("/usr/local/etc/Properties"); if (newFile.exists()) { newFile.delete(); } try { FileUtils.writeByteArrayToFile(newFile, file.getBytes()); propertyNameService.updateFromXml(newFile); ras.addFlashAttribute("error", propertyNameService.getResult().getErrors()); } catch (Exception e) { //ras.addFlashAttribute("error", "updateFromXml"+e.getMessage()); throw new Exception(StringAdapter.getStackTraceException(e)); } if (newFile.exists()) { newFile.delete(); } } ras.addAttribute("propId", propId); return "redirect:/PropertyName/show"; }
From source file:controllers.StrategyController.java
@RequestMapping("/deleteFailReason") public String deleteFailReason(Map<String, Object> model, RedirectAttributes ras, HttpServletRequest request, @RequestParam(value = "failReasonIdtoDelete") Long failReasonId, @RequestParam(value = "strategyId") Long strategyId) throws Exception { lk.dataByUserAndCompany(request, model); Long cabinetId = (Long) request.getSession().getAttribute(CABINET_ID_SESSION_NAME); ;//from w w w. j av a 2 s. c o m failReasonService.delete(failReasonId); /*if (failReasonService.getErrors().isEmpty()) { ras.addFlashAttribute("message", " " + failReasonService.getFailReason(failReasonId) + " "); }*/ ras.addFlashAttribute("errors", failReasonService.getErrors()); ras.addAttribute("strategyId", strategyId); return "redirect:/Strategy/failReasonEditor"; }
From source file:controllers.SequenceController.java
@RequestMapping("/updateFromXml") public String updateFromXml(Map<String, Object> model, @RequestParam(value = "xlsFile", required = false) MultipartFile file, @RequestParam(value = "sequenceId", required = true) Long sequenceId, RedirectAttributes ras) { if (file == null || file.isEmpty()) { ras.addFlashAttribute("error", "File not found"); } else {/* w ww. j a va 2 s . c o m*/ File newFile = new File("/usr/local/etc/sceneParamsList"); if (newFile.exists()) { newFile.delete(); } try { FileUtils.writeByteArrayToFile(newFile, file.getBytes()); sequenceService.updateFromXml(newFile, sequenceId); ras.addFlashAttribute("error", sequenceService.getResult().getErrors()); } catch (Exception e) { ras.addFlashAttribute("error", "updateFromXml" + StringAdapter.getStackTraceException(e)/*e.getMessage()*/); } if (newFile.exists()) { newFile.delete(); } } ras.addAttribute("sequenceId", sequenceId); return "redirect:/Sequence/showOne"; }
From source file:org.wallride.web.controller.admin.system.SystemIndexController.java
@Transactional(propagation = Propagation.REQUIRED) @RequestMapping(value = "/clear-cache", method = RequestMethod.POST) public String clearCache(@PathVariable String language, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) throws Exception { WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext, "org.springframework.web.servlet.FrameworkServlet.CONTEXT.guestServlet"); if (context == null) { throw new ServiceException("GuestServlet is not ready yet"); }/*from w w w .j ava 2 s.c om*/ DefaultModelAttributeInterceptor interceptor = context.getBean(DefaultModelAttributeInterceptor.class); ModelAndView mv = new ModelAndView("dummy"); interceptor.postHandle(request, response, this, mv); SpringTemplateEngine templateEngine = context.getBean("templateEngine", SpringTemplateEngine.class); logger.info("Clear cache started"); templateEngine.clearTemplateCache(); logger.info("Clear cache finished"); redirectAttributes.addFlashAttribute("clearCache", true); redirectAttributes.addAttribute("language", language); return "redirect:/_admin/{language}/system"; }
From source file:co.propack.controller.cart.CartController.java
@RequestMapping("/updateQuantity") public String updateQuantity(HttpServletRequest request, HttpServletResponse response, Model model, RedirectAttributes redirectAttributes, @ModelAttribute("addToCartItem") AddToCartItem addToCartItem) throws IOException, PricingException, UpdateCartException, RemoveFromCartException { try {/* w w w . j a v a 2 s. c om*/ return super.updateQuantity(request, response, model, addToCartItem); } catch (UpdateCartException e) { if (e.getCause() instanceof InventoryUnavailableException) { // Since there was an exception, the order gets detached from the Hibernate session. This re-attaches it CartState.setCart(orderService.findOrderById(CartState.getCart().getId())); if (isAjaxRequest(request)) { model.addAttribute("errorMessage", "Not enough inventory to fulfill your requested amount of " + addToCartItem.getQuantity()); return getCartView(); } else { redirectAttributes.addAttribute("errorMessage", "Not enough inventory to fulfill your requested amount of " + addToCartItem.getQuantity()); return getCartPageRedirect(); } } else { throw e; } } }
From source file:io.pivotal.cla.mvc.IclaController.java
@RequestMapping(value = "/sign/{claName}/icla", method = RequestMethod.POST) public String signCla(@AuthenticationPrincipal User user, @Valid SignClaForm signClaForm, BindingResult result, Map<String, Object> model, RedirectAttributes redirect) throws Exception { String claName = signClaForm.getClaName(); Integer pullRequestId = signClaForm.getPullRequestId(); String repositoryId = signClaForm.getRepositoryId(); ContributorLicenseAgreement cla = clas.findOne(signClaForm.getClaId()); if (result.hasErrors()) { model.put("cla", cla); return "cla/icla/sign"; }/*from w ww. j a v a2 s.c om*/ IndividualSignature signature = new IndividualSignature(); signature.setCla(cla); signature.setName(signClaForm.getName()); signature.setCountry(signClaForm.getCountry()); signature.setEmail(signClaForm.getEmail()); signature.setMailingAddress(signClaForm.getMailingAddress()); signature.setDateOfSignature(new Date()); signature.setTelephone(signClaForm.getTelephone()); signature.setGitHubLogin(user.getGitHubLogin()); individual.save(signature); // update github redirect.addAttribute("claName", claName); if (repositoryId == null || pullRequestId == null) { return "redirect:/sign/{claName}/icla"; } ClaPullRequestStatusRequest updatePullRequest = signClaForm .createUpdatePullRequestStatus(user.getGitHubLogin()); if (updatePullRequest != null) { updatePullRequest.getCommitStatus().setSuccess(true); claService.savePullRequestStatus(updatePullRequest); } redirect.addAttribute("repositoryId", repositoryId); redirect.addAttribute("pullRequestId", pullRequestId); return "redirect:/sign/{claName}/icla"; }