List of usage examples for org.springframework.ui Model asMap
Map<String, Object> asMap();
From source file:org.wallride.web.controller.admin.article.ArticleEditController.java
@RequestMapping(method = RequestMethod.GET) public String edit(@PathVariable String language, @RequestParam long id, Model model, RedirectAttributes redirectAttributes) { Article article = (Article) model.asMap().get("article"); if (article == null) { throw new HttpNotFoundException(); }/*from w w w . j ava 2s . c o m*/ if (!article.getLanguage().equals(language)) { Article target = articleService.getArticleByCode(article.getCode(), language); if (target != null) { redirectAttributes.addAttribute("id", target.getId()); return "redirect:/_admin/{language}/articles/edit?id={id}"; } else { redirectAttributes.addFlashAttribute("original", article); redirectAttributes.addAttribute("code", article.getCode()); return "redirect:/_admin/{language}/articles/create?code={code}"; } } Set<CustomField> customFields = customFieldService.getAllCustomFields(language); ArticleEditForm form = ArticleEditForm.fromDomainObject(article, customFields); model.addAttribute("form", form); Article draft = articleService.getDraftById(id); model.addAttribute("draft", draft); return "article/edit"; }
From source file:org.kew.rmf.matchconf.web.CustomTransformerController.java
@RequestMapping(value = "/{configType}_configs/{configName}/transformers/{transformerName}", method = RequestMethod.DELETE, produces = "text/html") public String delete(@PathVariable("configType") String configType, @PathVariable("configName") String configName, @PathVariable("transformerName") String transformerName, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception { Configuration config = Configuration.findConfigurationsByNameEquals(configName).getSingleResult(); config.removeTransformer(transformerName); uiModel.asMap().clear(); uiModel.addAttribute("page", (page == null) ? "1" : page.toString()); uiModel.addAttribute("size", (size == null) ? "10" : size.toString()); return "redirect:/{configType}_configs/" + configName.toString() + "/transformers/"; }
From source file:eu.europa.ec.eci.oct.webcommons.controller.HttpGetController.java
protected List<Language> getLanguageList(Model model, HttpServletRequest request) { @SuppressWarnings("unchecked") List<Language> ll = (List<Language>) model.asMap().get(CommonControllerConstants.MODEL_ATTRIBUTE_LANGUAGES); processLanguageList(request, ll);/*from ww w. jav a2 s .c o m*/ return ll; }
From source file:fr.univrouen.poste.web.admin.GalaxieExcelController.java
@RequestMapping(value = "/addFile", method = RequestMethod.POST, produces = "text/html") public String addFile(@Valid GalaxieExcel galaxieExcel, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws IOException, SQLException { if (bindingResult.hasErrors()) { logger.warn(bindingResult.getAllErrors()); return "redirect:/admin/galaxieexcels"; }//www. ja v a 2 s . c om uiModel.asMap().clear(); // upload file MultipartFile file = galaxieExcel.getFile(); String filename = file.getOriginalFilename(); InputStream inputStream = file.getInputStream(); byte[] bytes = IOUtils.toByteArray(inputStream); galaxieExcel.setFilename(filename); galaxieExcel.getBigFile().setBinaryFile(new SerialBlob(bytes)); galaxieExcel.getBigFile().persist(); // set current date Calendar cal = Calendar.getInstance(); galaxieExcel.setCreation(cal.getTime()); // persist galaxieExcel.persist(); // process : generate GalaxieEntries galaxieExcelParser.process(galaxieExcel); return "redirect:/admin/galaxieexcels"; }
From source file:fr.univrouen.poste.web.admin.CommissionExcelController.java
@RequestMapping(value = "/addFile", method = RequestMethod.POST, produces = "text/html") public String addFile(@Valid CommissionExcel commissionExcel, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws IOException, SQLException { if (bindingResult.hasErrors()) { logger.warn(bindingResult.getAllErrors()); return "redirect:/admin/commissionexcels"; }/*from w w w . ja v a2 s. co m*/ uiModel.asMap().clear(); // upload file MultipartFile file = commissionExcel.getFile(); String filename = file.getOriginalFilename(); InputStream inputStream = file.getInputStream(); byte[] bytes = IOUtils.toByteArray(inputStream); commissionExcel.setFilename(filename); commissionExcel.getBigFile().setBinaryFile(new SerialBlob(bytes)); commissionExcel.getBigFile().persist(); // set current date Calendar cal = Calendar.getInstance(); commissionExcel.setCreation(cal.getTime()); // persist commissionExcel.persist(); // process : generate CommissionEntries commissionExcelParser.process(commissionExcel); return "redirect:/admin/commissionexcels"; }
From source file:com.utbm.formation.controller.AddCourseSessionController.java
/** * Ajout des sessions slectionnes et affichage du formulaire d'ajout des infos tudiants * @param data Liste des sessions slectionns * @param model Le model des donnes/*from w w w . j av a 2 s. c o m*/ * @return Retourne la liste des sessions slectionns avec leur nom */ @RequestMapping(value = "", method = POST) public ModelAndView listCourse(@RequestParam("selectCourse") List<Integer> data, Model model) { Iterable<Integer> selectedCourse = data; Map<Course_session, Integer> mapCourseSession = courseSessionService.getSessionNameById(data); model.addAttribute("selectedCourse", selectedCourse); model.addAttribute("selectedCourseName", mapCourseSession); return new ModelAndView("addCourseSession", model.asMap()); }
From source file:org.kew.rmf.matchconf.web.DictionaryController.java
@RequestMapping(method = RequestMethod.POST, produces = "text/html") public String create(@Valid Dictionary dictionary, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { this.customValidation(dictionary, bindingResult); if (bindingResult.hasErrors()) { populateEditForm(uiModel, dictionary); return "dictionaries/create"; }//w w w. ja v a2 s. c om uiModel.asMap().clear(); dictionary.persist(); return "redirect:/dictionaries/" + encodeUrlPathSegment(dictionary.getName(), httpServletRequest); }
From source file:org.kew.rmf.matchconf.web.DictionaryController.java
@RequestMapping(method = RequestMethod.PUT, produces = "text/html") public String update(@Valid Dictionary dictionary, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { this.customValidation(dictionary, bindingResult); if (bindingResult.hasErrors()) { populateEditForm(uiModel, dictionary); return "dictionaries/update"; }/*from w w w . j a va 2 s . com*/ uiModel.asMap().clear(); dictionary.merge(); return "redirect:/dictionaries/" + encodeUrlPathSegment(dictionary.getName(), httpServletRequest); }
From source file:org.busko.routemanager.web.admin.community.RouteOutlineController.java
@RequestMapping(method = RequestMethod.POST, produces = "text/html") public String create(@Valid RouteOutline routeOutline, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { if (bindingResult.hasErrors()) { populateEditForm(uiModel, routeOutline); return "admin/community/routeoutlines/create"; }/*from w w w .ja v a2s . c o m*/ uiModel.asMap().clear(); routeOutline.uploadFileData(); routeOutline.persist(); return "redirect:/admin/community/routeoutlines/" + encodeUrlPathSegment(routeOutline.getId().toString(), httpServletRequest); }
From source file:fr.univrouen.poste.web.admin.UserController.java
@RequestMapping(method = RequestMethod.PUT, produces = "text/html") public String update(@Valid User user, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { if (bindingResult.hasErrors()) { populateEditForm(uiModel, user); return "admin/users/update"; }/*from ww w . ja v a2 s. c o m*/ uiModel.asMap().clear(); if (user.getId() != null) { User savedUser = User.findUser(user.getId()); if (!user.getPassword().equals(savedUser.getPassword())) { user.setPassword(messageDigestPasswordEncoder.encodePassword(user.getPassword(), null)); if (user.getActivationDate() == null) { user.setActivationDate(new Date()); } } } else { user.setPassword(messageDigestPasswordEncoder.encodePassword(user.getPassword(), null)); if (user.getActivationDate() == null) { user.setActivationDate(new Date()); } } user.merge(); return "redirect:/admin/users/" + encodeUrlPathSegment(user.getId().toString(), httpServletRequest); }