List of usage examples for org.springframework.ui Model asMap
Map<String, Object> asMap();
From source file:org.esupportail.pay.web.admin.PayEvtController.java
@RequestMapping(value = "/{id}/addLogoFile", method = RequestMethod.POST, produces = "text/html") @PreAuthorize("hasPermission(#id, 'manage')") public String addLogoFile(@PathVariable("id") Long id, UploadFile uploadFile, BindingResult bindingResult, Model uiModel, HttpServletRequest request) throws IOException { if (bindingResult.hasErrors()) { log.warn(bindingResult.getAllErrors()); return "redirect:/admin/evts/" + id.toString(); }/* w w w.java2 s . c om*/ uiModel.asMap().clear(); // get PosteCandidature from id PayEvt evt = PayEvt.findPayEvt(id); MultipartFile file = uploadFile.getLogoFile(); // sometimes file is null here, but I don't know how to reproduce this issue ... maybe that can occur only with some specifics browsers ? if (file != null) { Long fileSize = file.getSize(); //String contentType = file.getContentType(); //String filename = file.getOriginalFilename(); InputStream inputStream = file.getInputStream(); //byte[] bytes = IOUtils.toByteArray(inputStream); evt.getLogoFile().setBinaryFileStream(inputStream, fileSize); evt.getLogoFile().persist(); } return "redirect:/admin/evts/" + id.toString(); }
From source file:org.esupportail.pay.web.admin.PayEvtController.java
@RequestMapping(method = RequestMethod.PUT, produces = "text/html") @PreAuthorize("hasPermission(#payEvt, 'manage')") public String update(@Valid PayEvt payEvt, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { payEvtUpdateValidator.validate(payEvt, bindingResult); if (bindingResult.hasErrors()) { populateEditForm(uiModel, payEvt); return "admin/evts/update"; }//from w w w . jav a 2 s .c om uiModel.asMap().clear(); // Hack : don't override logoFile !! PayEvt payEvtCurrent = PayEvt.findPayEvt(payEvt.getId()); payEvt.setLogoFile(payEvtCurrent.getLogoFile()); // Hack end List<RespLogin> respLogins = new ArrayList<RespLogin>(); if (payEvt.getLogins() != null) { for (String login : payEvt.getLogins()) { RespLogin respLogin = RespLogin.findOrCreateRespLogin(login); respLogins.add(respLogin); } payEvt.setRespLogins(respLogins); } List<RespLogin> viewerLogins = new ArrayList<RespLogin>(); if (payEvt.getViewerLogins2Add() != null) { for (String login : payEvt.getViewerLogins2Add()) { RespLogin respLogin = RespLogin.findOrCreateRespLogin(login); viewerLogins.add(respLogin); } } payEvt.setViewerLogins(viewerLogins); payEvt.merge(); return "redirect:/admin/evts/" + encodeUrlPathSegment(payEvt.getId().toString(), httpServletRequest); }
From source file:org.esupportail.pay.web.admin.PayEvtController.java
@RequestMapping(method = RequestMethod.POST, produces = "text/html") @PreAuthorize("hasRole('ROLE_ADMIN')") public String create(@Valid PayEvt payEvt, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { if (bindingResult.hasErrors()) { log.info(bindingResult.getAllErrors()); populateEditForm(uiModel, payEvt); return "admin/evts/create"; }//from ww w. j a v a2 s . c om uiModel.asMap().clear(); List<RespLogin> respLogins = new ArrayList<RespLogin>(); if (httpServletRequest.getParameterValues("logins") != null) { List<String> logins = Arrays.asList(httpServletRequest.getParameterValues("logins")); for (String login : logins) { RespLogin respLogin = RespLogin.findOrCreateRespLogin(login); respLogins.add(respLogin); } } payEvt.setRespLogins(respLogins); List<RespLogin> viewerLogins = new ArrayList<RespLogin>(); if (httpServletRequest.getParameterValues("viewerLogins2Add") != null) { List<String> logins = Arrays.asList(httpServletRequest.getParameterValues("viewerLogins2Add")); for (String login : logins) { RespLogin respLogin = RespLogin.findOrCreateRespLogin(login); viewerLogins.add(respLogin); } } payEvt.setViewerLogins(viewerLogins); if (payEvt.getUrlId() == null || payEvt.getUrlId().isEmpty()) { String urlId = urlIdService.generateUrlId4PayEvt(payEvt.getTitle().getTranslation(Label.LOCALE_IDS.en)); payEvt.setUrlId(urlId); } payEvt.persist(); return "redirect:/admin/evts/" + encodeUrlPathSegment(payEvt.getId().toString(), httpServletRequest); }
From source file:org.esupportail.pay.web.admin.PayEvtController.java
@PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html") public String delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) { PayEvt payEvt = PayEvt.findPayEvt(id); payEvt.remove();/* w w w . j av a 2 s. c o m*/ uiModel.asMap().clear(); uiModel.addAttribute("page", (page == null) ? "1" : page.toString()); uiModel.addAttribute("size", (size == null) ? "10" : size.toString()); return "redirect:/admin/evts"; }
private AnyCurricularCourseExceptionsConfigurationBean getAnyCurricularCourseExceptionsConfigurationBean( Model model) { return (AnyCurricularCourseExceptionsConfigurationBean) model.asMap() .get("anyCurricularCourseExceptionsConfigurationBean"); }
private AnyCurricularCourseExceptionsConfiguration getAnyCurricularCourseExceptionsConfiguration(Model model) { return (AnyCurricularCourseExceptionsConfiguration) model.asMap() .get("anyCurricularCourseExceptionsConfiguration"); }
From source file:org.fenixedu.ulisboa.specifications.ui.evaluation.config.managemarksheetsettings.MarkSheetSettingsController.java
private MarkSheetSettings getMarkSheetSettings(Model model) { return (MarkSheetSettings) model.asMap().get("markSheetSettings"); }
From source file:org.fenixedu.ulisboa.specifications.ui.evaluation.managemarksheet.administrative.CompetenceCourseMarkSheetController.java
private CompetenceCourseMarkSheetBean getCompetenceCourseMarkSheetBean(final Model model) { return (CompetenceCourseMarkSheetBean) model.asMap().get("competenceCourseMarkSheetBean"); }
From source file:org.fenixedu.ulisboa.specifications.ui.evaluation.managemarksheet.administrative.CompetenceCourseMarkSheetController.java
private CompetenceCourseMarkSheet getCompetenceCourseMarkSheet(final Model model) { return (CompetenceCourseMarkSheet) model.asMap().get("competenceCourseMarkSheet"); }
From source file:org.fenixedu.ulisboa.specifications.ui.ff.moodleexport.MoodleExportController.java
private MoodleExportBean getMoodleExportBean(Model model) { return (MoodleExportBean) model.asMap().get("MoodleExportBean"); }