List of usage examples for org.springframework.web.servlet.mvc.support RedirectAttributes addAttribute
@Override RedirectAttributes addAttribute(String attributeName, @Nullable Object attributeValue);
From source file:controllers.StrategyController.java
@RequestMapping("/addModule") public String addModule(Map<String, Object> model, HttpServletRequest request, @RequestParam(value = "strategyId") Long strategyId, @RequestParam(value = "groupId") Long groupId, @RequestParam(value = "moduleName") String moduleName, RedirectAttributes ras) throws Exception { lk.dataByUserAndCompany(request, model); Long cabinetId = (Long) request.getSession().getAttribute(CABINET_ID_SESSION_NAME); Long moduleId = moduleService.saveModule(groupId, moduleName, cabinetId); ras.addFlashAttribute("errors", moduleService.getErrors()); ras.addAttribute("strategyId", strategyId); ras.addAttribute("groupId", groupId); ras.addAttribute("moduleId", moduleId); return "redirect:/Strategy/strategy"; }
From source file:controllers.AdController.java
@RequestMapping("/changeStatus") public String changeStatus(Map<String, Object> model, HttpServletRequest request, @RequestParam(value = "adId", required = false) Long adId, @RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "wish", required = false) String wish, RedirectAttributes ras) throws Exception { ArrayList<String> errors = new ArrayList(); User u = authManager.getCurrentUser(); if (u != null && User.ROLEADMIN.equals(u.getUserRole())) { adService.changeStatus(status, adId); }//www. j av a2 s. c o m errors.addAll(adService.getErrors()); ras.addAttribute("wish", wish); ras.addFlashAttribute(ERRORS_LIST_NAME, errors); return "redirect:/Main/"; }
From source file:com.stitchgalaxy.sg_manager_web.ProductController.java
@RequestMapping(value = UrlConstants.URL_CATEGORY_ADD, method = RequestMethod.POST) public String addCategory(Model model, @RequestParam(value = "category") Long categoryId, @RequestParam(value = "product") Long productId, @RequestParam(value = "name") String name, RedirectAttributes redirectAttributes) throws DomainDataServiceException { CommandCreateSubcategory command = new CommandCreateSubcategory(); command.setCategoryId(categoryId);//w w w. j a v a2 s. c o m command.setName(name); domainDataService.createSubcategory(command); redirectAttributes.addAttribute("category", categoryId); return "redirect:" + UrlConstants.URL_PRODUCT_SELECT_CATEGORY + "?product=" + productId + "&category=" + categoryId; }
From source file:it.polimi.diceH2020.launcher.controller.LaunchAnalysis.java
@RequestMapping(value = "/simulationSetupSingleInputData", method = RequestMethod.GET) public String showSimulationsManagerFormSingleData(SessionStatus sessionStatus, Model model, @ModelAttribute("instanceData") String instanceDataPath, @ModelAttribute("pathList") ArrayList<String> pathList, @ModelAttribute("scenario") String scenarioString, RedirectAttributes redirectAttrs) { Scenarios scenario = Scenarios.valueOf(scenarioString); model.addAttribute("scenario", scenario); redirectAttrs.addAttribute("scenario", scenario); if (pathList.size() == 0) { deleteUploadedFiles(pathList);// ww w .j a va 2s . c om redirectAttrs.addAttribute("message", "You haven't submitted any file!"); return "redirect:/launchRetry"; } if (instanceDataPath == null) { redirectAttrs.addAttribute("message", "Select a Json file!"); deleteUploadedFiles(pathList); return "redirect:/launchRetry"; } InstanceDataMultiProvider instanceData = validator .objectFromPath(Paths.get(instanceDataPath), InstanceDataMultiProvider.class).get(); String check = scenarioValidation(instanceData, scenario); if (!check.equals("ok")) { redirectAttrs.addAttribute("message", check); deleteUploadedFiles(pathList); return "redirect:/launchRetry"; } List<InstanceDataMultiProvider> inputList = new ArrayList<>(); inputList.add(instanceData); if (inputList.size() > 1) { List<String> providersList = inputList.stream().map(InstanceDataMultiProvider::getProvider) .collect(Collectors.toList()); if (!minNumTxt(providersList, pathList)) { deleteUploadedFiles(pathList); model.addAttribute("message", "Not enough TXT files selected.\nFor each provider in your JSON there must be 2 TXT files containing in their name the provider name."); return "redirect:/launchRetry"; } } List<SimulationsManager> simManagerList = initializeSimManagers(inputList); List<String> txtFoldersList = new ArrayList<>(); for (SimulationsManager sm : simManagerList) { sm.setInputFileName(Paths.get(instanceDataPath).getFileName().toString()); String txtFolder = new String(); try { txtFolder = fileUtility.createInputSubFolder(); txtFoldersList.add(txtFolder); } catch (Exception e) { deleteUploadedFiles(pathList); deleteUploadedFiles(txtFoldersList); redirectAttrs.addAttribute("message", "Too many folders for TXTs with the same name have been created!"); return "redirect:/launchRetry"; } InstanceDataMultiProvider input = sm.getInputData(); for (Entry<String, Map<String, Map<String, JobProfile>>> jobIDs : input.getMapJobProfiles() .getMapJobProfile().entrySet()) { for (Entry<String, Map<String, JobProfile>> provider : jobIDs.getValue().entrySet()) { for (Entry<String, JobProfile> typeVMs : provider.getValue().entrySet()) { String secondPartOfTXTName = getSecondPartOfReplayersName(jobIDs.getKey(), provider.getKey(), typeVMs.getKey()); List<String> txtToBeSaved = pathList.stream().filter(s -> s.contains(secondPartOfTXTName)) .filter(s -> s.contains(input.getId())).collect(Collectors.toList()); if (txtToBeSaved.isEmpty()) { deleteUploadedFiles(pathList); deleteUploadedFiles(txtFoldersList); model.addAttribute("message", "Missing TXT file for Instance:" + input.getId() + ", Job: " + jobIDs.getKey() + ", Provider:" + provider.getKey() + ", TypeVM:" + typeVMs.getKey()); return "redirect:/launchRetry"; } for (String srcPath : txtToBeSaved) { File src = new File(srcPath); String fileContent = new String(); try { fileUtility.copyFile(srcPath, txtFolder + src.getName()); } catch (IOException e) { deleteUploadedFiles(pathList); deleteUploadedFiles(txtFoldersList); model.addAttribute("message", "Problem with TXT paths. [TXT file for Instance:" + input.getId() + ", Job: " + jobIDs.getKey() + ", Provider:" + provider.getKey() + ", TypeVM:" + typeVMs.getKey() + "]"); return "redirect:/launchRetry"; } if (fileContent.length() == 0) { deleteUploadedFiles(pathList); deleteUploadedFiles(txtFoldersList); model.addAttribute("message", "Missing TXT file for Instance:" + input.getId() + ", Job: " + jobIDs.getKey() + ", Provider:" + provider.getKey() + ", TypeVM:" + typeVMs.getKey()); return "redirect:/launchRetry"; } sm.addInputFolder(txtFolder); sm.setNumCompletedSimulations(0); sm.buildExperiments(); } } } } } deleteUploadedFiles(pathList); for (SimulationsManager sm : simManagerList) { ds.simulation(sm); } model.addAttribute("simManagersList", simManagerList); return "redirect:/"; }
From source file:com.app.controller.SearchQueryController.java
@RequestMapping(value = "/update_search_query", method = RequestMethod.POST) public String updateSearchQuery(@ModelAttribute("searchQuery") SearchQuery searchQuery, RedirectAttributes redirectAttributes) throws DatabaseConnectionException, SQLException { try {// w w w.j av a 2 s .c o m SearchQueryUtil.updateSearchQuery(UserUtil.getCurrentUserId(), searchQuery); redirectAttributes.addFlashAttribute("currentSearchQueryId", searchQuery.getSearchQueryId()); redirectAttributes.addFlashAttribute("isCurrentSearchQueryActive", searchQuery.isActive()); } catch (SearchQueryException sqe) { redirectAttributes.addAttribute("searchQueryId", searchQuery.getSearchQueryId()); redirectAttributes.addFlashAttribute("error", LanguageUtil.getMessage("invalid-search-query")); return "redirect:update_search_query"; } return "redirect:view_search_queries"; }
From source file:controllers.PropertyController.java
@RequestMapping("/updatePropertyNames") public String updatePropertyNames(Map<String, Object> model, @RequestParam(value = "propId", required = true) Long propId, @RequestParam(value = "name", required = true) String name, @RequestParam(value = "audial", required = false) Long audial, @RequestParam(value = "visual", required = false) Long visual, @RequestParam(value = "kinestet", required = false) Long kinestet, @RequestParam(value = "percentValue", required = false) Long percentValue, @RequestParam(value = "paramValue", required = false) Double paramValue, @RequestParam(value = "rad", required = false) String rad, RedirectAttributes ras) throws Exception { //List<String> pnamelist = propertyNameService.getUniquePropertyNames(pnId); //List<PropertyName> pnamelist = propertyNameService.getUniquePropertyNames(propId); if (propId != null && name != null && !name.equals("")) { propertyNameService.updateByNameAndPropertyId(name, propId, percentValue, paramValue, audial, visual, kinestet, rad);/* w ww . jav a 2 s. c om*/ /*List<PropertyName> plist = propertyNameService.getProperties(carId); model.put("props", plist);*/ } ras.addAttribute("propId", propId); /*model.put("uniquePropNames", pnamelist); model.put("oldPropertyId", propId);*/ return "redirect:/PropertyName/show"; }
From source file:controllers.LkController.java
@RequestMapping("/setTarif") public String setTarif(Map<String, Object> model, RedirectAttributes ras, @RequestParam(value = "tarifId") Long tarifId, @RequestParam(value = "pkId") Long pkId, HttpServletRequest request) throws Exception { dataByUserAndCompany(request, model); List<String> errors = (List<String>) model.get("errors"); if (errors == null) { errors = new ArrayList(); }//from w w w. j a va2 s . c om if (isSuperAdmin()) { adminService.setTarif(tarifId, pkId); errors.addAll(adminService.getErrors()); ras.addAttribute("pkId", pkId); ras.addFlashAttribute("errors", errors); return "redirect:/Lk/administrating"; } else { return "redirect:/"; } }
From source file:controllers.SequenceController.java
@RequestMapping("/addParam") public String addParam(Map<String, Object> model, @RequestParam("sequenceId") Long sequenceId, @RequestParam("uid") String uid, @RequestParam("vmin") Long vmin, @RequestParam("vmax") Long vmax, @RequestParam("amin") Long amin, @RequestParam("amax") Long amax, RedirectAttributes ras) throws Exception { List<BaseParam> bpList = baseParamService.getParams(); BaseParam bp = baseParamService.getBaseParam(bpList, uid); SequenceValueRange svr = new SequenceValueRange(); svr.setSequence(sequenceService.find(sequenceId)); svr.setUid(uid);//from w ww . j av a 2s.c om svr.setName(bp.getName()); svr.setValueMin(vmin); svr.setValueMax(vmax); svr.setAmin(amin); svr.setAmax(amax); sequenceValueRangeService.create(svr); ras.addAttribute("sequenceId", sequenceId); //ras.addFlashAttribute("baseParamsList", bpList); return "redirect:/Sequence/showOne"; }
From source file:org.wallride.web.controller.guest.article.ArticleDescribeController.java
@RequestMapping public String describe(@PathVariable int year, @PathVariable int month, @PathVariable int day, @PathVariable String code, BlogLanguage blogLanguage, Model model, RedirectAttributes redirectAttributes) { Article article = articleService.getArticleByCode(code, blogLanguage.getLanguage()); if (article == null) { article = articleService.getArticleByCode(code, blogLanguage.getBlog().getDefaultLanguage()); }/*from ww w . j av a 2 s. co m*/ if (article == null) { throw new HttpNotFoundException(); } if (article.getStatus() != Post.Status.PUBLISHED) { throw new HttpNotFoundException(); } LocalDate date = LocalDate.of(year, month, day); if (!article.getDate().toLocalDate().equals(date)) { redirectAttributes.addAttribute("year", article.getDate().getYear()); redirectAttributes.addAttribute("month", article.getDate().getMonth().getValue()); redirectAttributes.addAttribute("day", article.getDate().getDayOfMonth()); redirectAttributes.addAttribute("code", code); return "redirect:/{year}/{month}/{day}/{code}"; } CommentSearchRequest request = new CommentSearchRequest(); request.setPostId(article.getId()); request.setApproved(Boolean.TRUE); Page<Comment> comments = commentService.getComments(request, new PageRequest(0, 1000)); List<Long> ids = articleService.getArticleIds(new ArticleSearchRequest().withStatus(Post.Status.PUBLISHED)); if (!CollectionUtils.isEmpty(ids)) { int index = ids.indexOf(article.getId()); if (index < ids.size() - 1) { Article next = articleService.getArticleById(ids.get(index + 1)); model.addAttribute("next", next); } if (index > 0) { Article prev = articleService.getArticleById(ids.get(index - 1)); model.addAttribute("prev", prev); } } model.addAttribute("article", article); model.addAttribute("comments", comments); return "article/describe"; }
From source file:fr.univrouen.poste.web.admin.LogMailController.java
@RequestMapping(value = "/{id}/resend") @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPER_MANAGER')") public String resendEmail(@PathVariable("id") Long id, RedirectAttributes ra) { // With 'RedirectAttributes ra' we disable here adding model attributes in request header when redirecting ... LogMail logMail = LogMail.findLogMail(id); String mailTo = logMail.getMailTo(); String mailMessage = logMail.getMessage(); // TODO : get mailSubject from logMail ... //String mailSubject = logMail.getSubject(); String mailSubject = AppliConfig.getCacheMailSubject(); String mailFrom = AppliConfig.getCacheMailFrom(); Boolean emailSent = emailService.sendMessage(mailFrom, mailTo, mailSubject, mailMessage); ra.addAttribute("emailSent", emailSent); return "redirect:/admin/logmails/" + id.toString(); }