List of usage examples for org.springframework.ui Model addAllAttributes
Model addAllAttributes(Map<String, ?> attributes);
From source file:ru.mystamps.web.controller.SeriesController.java
@PostMapping(Url.ADD_IMAGE_SERIES_PAGE) public String processImage(@Valid AddImageForm form, BindingResult result, @PathVariable("id") Integer seriesId, Model model, @CurrentUser Integer currentUserId, Locale userLocale, HttpServletResponse response) throws IOException { if (seriesId == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }/* w ww .ja v a2 s .c o m*/ String lang = LocaleUtils.getLanguageOrNull(userLocale); SeriesDto series = seriesService.findFullInfoById(seriesId, lang); if (series == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } boolean maxQuantityOfImagesExceeded = !isAdmin() && !isAllowedToAddingImages(series); model.addAttribute("maxQuantityOfImagesExceeded", maxQuantityOfImagesExceeded); if (result.hasErrors() || maxQuantityOfImagesExceeded) { Map<String, ?> commonAttrs = prepareCommonAttrsForSeriesInfo(series, currentUserId); model.addAllAttributes(commonAttrs); addSeriesSalesFormToModel(model); // don't try to re-display file upload field form.setImage(null); return "series/info"; } seriesService.addImageToSeries(form, series.getId(), currentUserId); return redirectTo(Url.INFO_SERIES_PAGE, series.getId()); }
From source file:com.redhat.rhtracking.web.controller.OpportunityController.java
/** * //ww w. j a va2 s. c om * @param page * @param size * @param sort the column to find by * 0: default, by last created; * 1: id; * 2: project; * 3: customer; * 4: total hours; * 5: accrued hours. * @param asc 1: ascending order, descending otherwise * @param find * @param model * @return */ @RequestMapping(value = "/opportunity/", method = RequestMethod.GET) public String list(@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "20") int size, @RequestParam(required = false, defaultValue = "0") int sort, @RequestParam(required = false, defaultValue = "0") int asc, @RequestParam(required = false, defaultValue = "") String find, Model model) { Map<String, Object> request = new HashMap<>(); request.put("pageNumber", page - 1); request.put("pageSize", size > 9 ? size : 20); switch (sort) { case 1: request.put("sort", "identifier"); break; case 2: request.put("sort", "project"); break; case 3: request.put("sort", "customerName"); break; case 4: request.put("sort", "totalHours"); break; case 5: request.put("sort", "accruedHours"); break; case 6: break; case 10: request.put("sort", "likeProject"); request.put("like", find); break; case 11: request.put("sort", "likeIdentifier"); request.put("like", find); break; } if (asc == 1) request.put("asc", true); Map<String, Object> response = deliveryMatrixService.listAllOpportunitiesPaged(request); if ((EventStatus) response.get("status") == EventStatus.SUCCESS) { model.addAttribute("asc", asc); model.addAttribute("sort", sort); model.addAllAttributes(response); } else getMessagesList(model).add("error::Ocurrio un error al obtener al procesar la solicitud"); for (String key : response.keySet()) { if (key.equals("page")) continue; logger.debug(key + ": " + response.get(key)); } return "/opportunity/list"; }
From source file:aiai.ai.launchpad.experiment.ExperimentsController.java
@GetMapping(value = "/experiment-feature-progress/{experimentId}/{featureId}") public String getSequences(Model model, @PathVariable Long experimentId, @PathVariable Long featureId, final RedirectAttributes redirectAttributes) { Experiment experiment = experimentRepository.findById(experimentId).orElse(null); if (experiment == null) { redirectAttributes.addFlashAttribute("errorMessage", "#280.01 experiment wasn't found, experimentId: " + experimentId); return "redirect:/launchpad/experiments"; }//from w ww. j a v a 2s . co m ExperimentFeature experimentFeature = experimentFeatureRepository.findById(featureId).orElse(null); if (experimentFeature == null) { redirectAttributes.addFlashAttribute("errorMessage", "#280.02 feature wasn't found, experimentFeatureId: " + featureId); return "redirect:/launchpad/experiments"; } Map<String, Object> map = experimentService.prepareExperimentFeatures(experiment, experimentFeature); model.addAllAttributes(map); return "launchpad/experiment-feature-progress"; }
From source file:mx.edu.um.mateo.activos.web.ActivoController.java
@RequestMapping("/depreciacionMensualPorCentroDeCosto") public String depreciacionMensualPorCentroDeCosto(HttpServletRequest request, HttpServletResponse response, Model modelo, @RequestParam(required = false) String fecha, @RequestParam(required = false) Byte hojaCalculo) throws ParseException, IOException { log.debug("Depreciacion Mensual por Centro de Costo {}", fecha); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MM-yyyy"); if (fecha != null) { Date date = sdf.parse(fecha); Map<String, Object> params = new HashMap<>(); params.put("usuario", ambiente.obtieneUsuario()); params.put("fecha", date); params = activoDao.depreciacionMensualPorCentroDeCosto(params); if (hojaCalculo == 1) { response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename='depreciacionMensualPorCentroDeCosto-" + sdf2.format(date) + ".xlsx'"); params.put("out", response.getOutputStream()); activoDao.hojaCalculoDepreciacion(params); return null; }// w ww . j a v a 2 s. co m modelo.addAllAttributes(params); modelo.addAttribute("fecha", fecha); modelo.addAttribute("fechaParam", sdf2.format(date)); } else { modelo.addAttribute("fecha", sdf.format(new Date())); modelo.addAttribute("fechaParam", sdf2.format(new Date())); } return "activoFijo/activo/depreciacionMensualPorCentroDeCosto"; }
From source file:mx.edu.um.mateo.activos.web.ActivoController.java
@RequestMapping("/depreciacionAcumuladaPorGrupo") public String depreciacionAcumuladaPorGrupo(HttpServletRequest request, HttpServletResponse response, Model modelo, @RequestParam(required = false) String fecha, @RequestParam(required = false) Byte hojaCalculo) throws ParseException, IOException { log.debug("Depreciacion Acumulada por Tipo de Activo {}", fecha); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MM-yyyy"); if (fecha != null) { Date date = sdf.parse(fecha); Map<String, Object> params = new HashMap<>(); params.put("usuario", ambiente.obtieneUsuario()); params.put("fecha", date); params = activoDao.depreciacionAcumuladaPorTipoActivo(params); if (hojaCalculo == 1) { response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename='depreciacionAcumuladaYMensualPorGrupo-" + sdf2.format(date) + ".xlsx'"); params.put("out", response.getOutputStream()); activoDao.hojaCalculoDepreciacion(params); return null; }/*from w w w .j av a2 s. c o m*/ modelo.addAllAttributes(params); modelo.addAttribute("fecha", fecha); modelo.addAttribute("fechaParam", sdf2.format(date)); } else { modelo.addAttribute("fecha", sdf.format(new Date())); modelo.addAttribute("fechaParam", sdf2.format(new Date())); } return "activoFijo/activo/depreciacionAcumuladaPorGrupo"; }
From source file:mx.edu.um.mateo.activos.web.ActivoController.java
@RequestMapping("/depreciacionAcumuladaPorCentroDeCosto") public String depreciacionAcumuladaPorCentroDeCosto(HttpServletRequest request, HttpServletResponse response, Model modelo, @RequestParam(required = false) String fecha, @RequestParam(required = false) Byte hojaCalculo) throws ParseException, IOException { log.debug("Depreciacion Acumulada por Centro de Costo {}", fecha); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MM-yyyy"); if (fecha != null) { Date date = sdf.parse(fecha); Map<String, Object> params = new HashMap<>(); params.put("usuario", ambiente.obtieneUsuario()); params.put("fecha", date); params = activoDao.depreciacionAcumuladaPorCentroDeCosto(params); if (hojaCalculo == 1) { response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename='depreciacionAcumuladaPorCentroDeCosto-" + sdf2.format(date) + ".xlsx'"); params.put("out", response.getOutputStream()); activoDao.hojaCalculoDepreciacion(params); return null; }/* w ww. j a v a 2 s .co m*/ modelo.addAllAttributes(params); modelo.addAttribute("fecha", fecha); modelo.addAttribute("fechaParam", sdf2.format(date)); } else { modelo.addAttribute("fecha", sdf.format(new Date())); modelo.addAttribute("fechaParam", sdf2.format(new Date())); } return "activoFijo/activo/depreciacionAcumuladaPorCentroDeCosto"; }
From source file:mx.edu.um.mateo.activos.web.ActivoController.java
@RequestMapping("/concentrado/depreciacionPorCentroDeCosto") public String concentradoDepreciacionPorCentroDeCosto(HttpServletRequest request, HttpServletResponse response, Model modelo, @RequestParam(required = false) String fecha, @RequestParam(required = false) Byte hojaCalculo) throws ParseException, IOException { log.debug("Concentrado de Depreciacion por Centro de Costo {}", fecha); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MM-yyyy"); if (fecha != null) { Date date = sdf.parse(fecha); Map<String, Object> params = new HashMap<>(); params.put("usuario", ambiente.obtieneUsuario()); params.put("fecha", date); params = activoDao.concentradoDepreciacionPorCentroDeCosto(params); if (hojaCalculo == 1) { response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename='concentradoDepreciacionPorCentroDeCosto-" + sdf2.format(date) + ".xlsx'"); params.put("out", response.getOutputStream()); activoDao.hojaCalculoConcentradoDepreciacion(params); return null; }//from ww w .j a va2 s . c o m modelo.addAllAttributes(params); modelo.addAttribute("fecha", fecha); modelo.addAttribute("fechaParam", sdf2.format(date)); } else { modelo.addAttribute("fecha", sdf.format(new Date())); modelo.addAttribute("fechaParam", sdf2.format(new Date())); } return "activoFijo/activo/concentradoDepreciacionPorCentroDeCosto"; }
From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java
@RequestMapping(value = "/login", method = RequestMethod.POST) public String loginAssistedServiceAgent(final Model model, final HttpServletRequest request, final HttpServletResponse response, @RequestParam("username") final String username, @RequestParam("password") final String password) { try {/* w w w . j a va 2 s .co m*/ assistedServiceFacade.loginAssistedServiceAgent(username, password); assistedServiceAgentLoginStrategy.login(username, request, response); assistedServiceFacade.emulateAfterLogin(); refreshSpringSecurityToken(); setSessionTimeout(); model.addAttribute(ASM_REDIRECT_URL_ATTRIBUTE, assistedServiceRedirectStrategy.getRedirectPath()); } catch (final AssistedServiceException e) { model.addAttribute(ASM_MESSAGE_ATTRIBUTE, e.getMessageCode()); model.addAttribute(ASM_ALERT_CLASS, e.getAlertClass()); model.addAttribute("username", this.encodeValue(username)); LOG.debug(e.getMessage(), e); } model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes()); return ASSISTED_SERVICE_COMPONENT; }
From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java
@RequestMapping(value = "/logoutasm", method = RequestMethod.POST) public String logoutAssistedServiceAgent(final Model model) { try {/*from w w w . ja va 2 s . co m*/ assistedServiceFacade.logoutAssistedServiceAgent(); } catch (final AssistedServiceException e) { model.addAttribute(ASM_MESSAGE_ATTRIBUTE, e.getMessage()); LOG.debug(e.getMessage(), e); } model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes()); model.addAttribute("customerReload", "reload"); return ASSISTED_SERVICE_COMPONENT; }
From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java
@RequestMapping(value = "/personify-customer", method = RequestMethod.POST) public String emulateCustomer(final Model model, @RequestParam("customerId") final String customerId, @RequestParam("customerName") final String customerName, @RequestParam("cartId") final String cartId) { try {/* w w w . ja v a2 s . com*/ assistedServiceFacade.emulateCustomer(customerId, cartId); refreshSpringSecurityToken(); model.addAttribute(ASM_REDIRECT_URL_ATTRIBUTE, assistedServiceRedirectStrategy.getRedirectPath()); } catch (final AssistedServiceException e) { model.addAttribute(ASM_MESSAGE_ATTRIBUTE, e.getMessageCode()); model.addAttribute(ASM_ALERT_CLASS, e.getAlertClass()); model.addAttribute("customerId", this.encodeValue(customerId)); model.addAttribute("cartId", this.encodeValue(cartId)); model.addAttribute("customerName", this.encodeValue(customerName)); LOG.debug(e.getMessage(), e); } model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes()); return ASSISTED_SERVICE_COMPONENT; }