List of usage examples for org.springframework.web.servlet ModelAndView addAllObjects
public ModelAndView addAllObjects(@Nullable Map<String, ?> modelMap)
From source file:com.hihsoft.baseclass.web.controller.javahihBaseController.java
/** * ?.//from w w w . ja v a 2 s . c om * * @param request * the request * @param response * the response * @return the model and view * @throws ControllerException * the ControllerException */ @RequestMapping(params = "method=delete") public ModelAndView delete(final HttpServletRequest request, final HttpServletResponse response) throws ControllerException { final ModelAndView mav = new ModelAndView(v_success); mav.addAllObjects(referenceData(request)); delete(request, response, mav); return mav; }
From source file:com.hihsoft.baseclass.web.controller.javahihBaseController.java
/** * .,??model. /* w ww . j a v a2 s.c o m*/ * {@link #onSave(HttpServletRequest,HttpServletResponse,ModelAndView,boolean)} * . * * @param request * the request * @param result * the result * @param mav * the mav * @param viewName * the view name * @return the model and view */ @RequestMapping(params = "method=bindError") protected ModelAndView bindError(final HttpServletRequest request, final BindingResult result, final ModelAndView mav, final String viewName) { mav.setViewName(viewName); mav.addAllObjects(result.getModel()); mav.addAllObjects(referenceData(request)); return mav; }
From source file:org.inbio.modeling.web.controller.ShowMapController.java
/** Default behavior on direct access */ @Override/*w ww . java 2 s . c o m*/ protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) { HttpSession session = null; ModelAndView model = null; // retrieve the session Information. CurrentInstanceData currentInstanceData = null; // retrieve the session Information. session = request.getSession(); currentInstanceData = SessionUtils.isSessionAlive(session); if (currentInstanceData == null) { Exception ex = new Exception("errors.noSession"); Logger.getLogger(ColumnController.class.getName()).log(Level.SEVERE, null, ex); errors.reject(ex.getMessage()); } // Send the layer list to the JSP model = new ModelAndView(); model.setViewName("showResultingMap"); model.addObject(filtersKey, filtersMap.getFilters()); model.addObject("exportForm", new ExportData()); model.addObject("fullSessionInfo", currentInstanceData); model.addObject("speciesLayers", layerManagerImpl.getSpeciesDistributionLayerList()); model.addObject("mainLayer", currentInstanceData.getLimitLayerName()); if (errors != null && errors.hasErrors()) model.addAllObjects(errors.getModel()); return model; }
From source file:com.itjenny.web.ArticleController.java
@RequestMapping(value = "{title}", method = RequestMethod.GET) public ModelAndView getArticle(@PathVariable String title) { ModelAndView mav = new ModelAndView(); ModelMap model = new ModelMap(); Integer chapterIndex = bookmarkService.getChapterIndex(title); List<Chapter> chapters = articleService.getChaptersToIndex(title, chapterIndex); if (chapters == null) { logger.info("title({}) isn't existed", title); return new ModelAndView("redirect:/" + URL.ARTICLE); }/*from w ww . j ava 2 s. co m*/ model.addAttribute("title", title); model.addAttribute("chapters", chapters); model.addAttribute("license", chapterIndex.equals(Consts.BOOKMARK_LICENSE)); model.addAttribute("totalSection", articleService.getTotalSection(title)); model.addAttribute("setting", settingService.get(sessionService.getLoginUser().getUserId())); String css = articleService.get(title).getCss(); if (StringUtils.isEmpty(css)) { model.addAttribute("css", themeService.getDefault().getCss()); } else { model.addAttribute("css", css); } mav.setViewName(View.ARTICLE); mav.addAllObjects(model); bookmarkService.updateChapter(title, 0); return mav; }
From source file:com.itjenny.web.ArticleController.java
@RequestMapping(value = "{title}/{chapterCssId}", method = RequestMethod.POST) public ModelAndView checkAnswer(HttpServletRequest request, @PathVariable String title, @PathVariable String chapterCssId, @RequestParam String answer) { Integer chapterIndex = Integer.valueOf(chapterCssId.replace(Consts.CHAPTER, StringUtils.EMPTY)); ModelAndView mav = new ModelAndView(); ModelMap model = new ModelMap(); for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("keynote")) { Article article = articleService.get(title); if (article == null || !article.getUserId().equals(sessionService.getLoginUser().getUserId())) { break; }// ww w. jav a2 s.c o m // keynote mode if (!articleService.isChapterExisted(title, chapterIndex + 1)) { bookmarkService.complete(title); return new ModelAndView("redirect:/article/" + title + "/license"); } model.addAttribute("chapter", articleService.getChapter(title, chapterIndex + 1)); model.addAttribute("totalSection", articleService.getTotalSection(title)); model.addAttribute("answer", articleService.getChapter(title, chapterIndex).getQuiz().getAnswer()); mav.setViewName(View.CHAPTER); mav.addAllObjects(model); bookmarkService.updateChapter(title, chapterIndex + 1); return mav; } } // word mode Chapter chapter = articleService.getChapter(title, chapterIndex); if (answerService.check(chapter, answer)) { if (!articleService.isChapterExisted(title, chapterIndex + 1)) { bookmarkService.complete(title); return new ModelAndView("redirect:/article/" + title + "/license"); } model.addAttribute("chapter", articleService.getChapter(title, chapterIndex + 1)); model.addAttribute("totalSection", articleService.getTotalSection(title)); model.addAttribute("answer", articleService.getChapter(title, chapterIndex).getQuiz().getAnswer()); mav.setViewName(View.CHAPTER); mav.addAllObjects(model); bookmarkService.updateChapter(title, chapterIndex + 1); } else { mav.setViewName(View.WRONG); mav.addAllObjects(model); } return mav; }
From source file:gemlite.core.webapp.tools.DataModelController.java
@RequestMapping(value = "/model", method = RequestMethod.POST) @ResponseBody//from w ww . j av a 2 s . c om public ModelAndView model(HttpServletRequest request, ModelAndView modelAndView) { modelAndView = new ModelAndView("tools/data_model"); String driver = StringUtils.trim((String) request.getParameter("driver")); String url = StringUtils.trim((String) request.getParameter("url")); String user = StringUtils.trim((String) request.getParameter("user")); String pwd = StringUtils.trim((String) request.getParameter("pwd")); String name = StringUtils.trim((String) request.getParameter("name")); String inputSchema = StringUtils.trim((String) request.getParameter("inputSchema")); String includes = StringUtils.trim((String) request.getParameter("includes")); String excludes = StringUtils.trim((String) request.getParameter("excludes")); String packageName = StringUtils.trim((String) request.getParameter("packageName")); String directory = StringUtils.trim((String) request.getParameter("directory")); DataModelConf conf = new DataModelConf(driver, url, user, pwd, name, inputSchema, includes, excludes, packageName, directory); try { HashMap<String, String> map = getValueMap(conf); modelAndView.addAllObjects(map); command.webExecute(driver, url, user, pwd, name, inputSchema, includes, excludes, packageName, directory); DataModelService service = JpaContext.getService(DataModelService.class); service.deleteAll(); service.save(conf); modelAndView.addObject("msg", "Successed!"); } catch (Exception e) { modelAndView.addObject("msg", "Failed! Please check the configuration. " + e); } return modelAndView; }
From source file:org.myjerry.evenstar.web.blog.ViewPostController.java
@SuppressWarnings("unchecked") public ModelAndView view(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mav = getModelAndView(request); Long blogID = StringUtils.getLong(request.getParameter("blogID")); Long postID = StringUtils.getLong(request.getParameter("postID")); Blog blog = this.blogService.getBlog(blogID); BlogPost post = this.blogPostService.getPost(postID, blogID); String olderPostUrl = this.blogPostService.getOlderPostUrl(blogID, post.getPostedDate()); String newerPostUrl = this.blogPostService.getNewerPostUrl(blogID, post.getPostedDate()); Map<String, Object> model = new HashMap<String, Object>(); model.put("olderPageUrl", olderPostUrl); model.put("newerPageUrl", newerPostUrl); boolean viewComments = StringUtils.getBoolean( this.blogPreferenceService.getPreference(blogID, BlogPreferenceConstants.showPostComments), true); model.putAll(mav.getModel());/*from w ww .java2s . c om*/ model = this.viewPostService.getPostsViewModel(blog, Arrays.asList(post), viewComments, model); String generatedBlogPage = TemplateHelper.generateBlogPage(blogID, model, blogLayoutService, velocityEngine); mav.addAllObjects(model); mav.addObject("generatedBlogPage", generatedBlogPage); mav.setViewName(".view.blog.home"); return mav; }
From source file:org.inbio.modeling.web.controller.ColumnController.java
/** * If hit the /columns.html address directly you will be redirected to index * @param request/* w ww. ja v a 2s . c o m*/ * @param response * @param errors * @return * @throws Exception */ @Override protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) { CurrentInstanceData currentInstanceData = null; ChooseColumnForm cForm = null; Long currentSessionId = null; HttpSession session = null; List<Layer> layers = null; ModelAndView model = null; // retrieve the session Information. session = request.getSession(); currentInstanceData = SessionUtils.isSessionAlive(session); if (currentInstanceData != null && errors != null && !errors.hasErrors()) { currentSessionId = currentInstanceData.getUserSessionId(); layers = currentInstanceData.getLayerList(); try { // Asign the type to the layer. layers = this.asingType2Layer(layers, currentSessionId); // retrieve dataColumns layers = this.retrieveColumns(layers, currentSessionId); } catch (Exception ex) { Logger.getLogger(ColumnController.class.getName()).log(Level.SEVERE, null, ex); errors.reject(ex.getMessage()); } } // asing the columns to the jsp. cForm = new ChooseColumnForm(); cForm.setLayers(layers); // Send the layer list to the JSP model = new ModelAndView(); model.setViewName("columns"); model.addObject("columnsForm", cForm); if (errors != null && errors.hasErrors()) { model.addAllObjects(errors.getModel()); } return model; }
From source file:org.sventon.web.ctrl.template.DiffController.java
@Override protected ModelAndView svnHandle(final SVNConnection connection, final BaseCommand cmd, final long headRevision, final UserRepositoryContext userRepositoryContext, final HttpServletRequest request, final HttpServletResponse response, final BindException exception) throws Exception { final DiffCommand command = (DiffCommand) cmd; final Map<String, Object> model = new HashMap<String, Object>(); final ModelAndView modelAndView = new ModelAndView(); final String charset = userRepositoryContext.getCharset(); handleDiffPrevious(connection, command); handleDiffStyle(command);/*w ww. j av a2 s. co m*/ try { final DirEntry.Kind nodeKind = getRepositoryService().getNodeKind(connection, command.getPath(), command.getRevisionNumber()); model.put("isFile", DirEntry.Kind.FILE == nodeKind); final DirEntry.Kind nodeKindForDiff = getRepositoryService().getNodeKindForDiff(connection, command.getFrom(), command.getTo(), command.getPegRevision()); if (DirEntry.Kind.DIR == nodeKindForDiff) { model.putAll(handlePathDiff(connection, modelAndView, command)); } else if (DirEntry.Kind.FILE == nodeKindForDiff) { model.putAll(handleFileDiff(connection, modelAndView, command, charset)); } else { throw new DiffException("Unable to diff entry of kind: " + nodeKindForDiff); } } catch (final IdenticalFilesException ife) { logger.debug("Files are identical"); model.put("isIdentical", true); } catch (final IllegalFileFormatException iffe) { logger.info(iffe.getMessage()); model.put("isBinary", true); // Indicates that one or both files are in binary format. } modelAndView.addAllObjects(model); return modelAndView; }
From source file:de.interseroh.report.controller.ReportController.java
@RequestMapping(method = RequestMethod.GET) public ModelAndView showReportForm( ///*w w w . ja va2 s .com*/ @ModelAttribute ParameterForm parameterForm, // @RequestParam MultiValueMap<String, String> requestParams, @PathVariable("reportName") String reportName, BindingResult errors) throws BirtReportException { logger.debug("executing show report for " + reportName); checkPermisionFor(reportName); ModelAndView modelAndView = new ModelAndView(); parameterFormBinder.bind(parameterForm, requestParams, errors); parameterFormConverter.convert(parameterForm, errors); if (parameterForm.isValid()) { Pagination pagination = reportService.getPageInfos(reportName, parameterForm); // TODO reportPage // if (reportPage.getCurrentPageNumber() > reportPage // .getPageNumbers()) { // throw new BirtReportException(String.format( // "For this report: %s no more pages available", // reportName)); // } modelAndView.addObject("pagination", pagination); modelAndView.setViewName("/report"); injectReportUri(parameterForm, modelAndView, reportName); configSetter.setVersion(modelAndView); configSetter.setBranding(modelAndView); } else { // show parameters RedirectView redirectView = new RedirectView(); redirectView.setUrl("/reports/{reportName}/params"); redirectView.setContextRelative(true); redirectView.setPropagateQueryParams(false); redirectView.setExposeModelAttributes(true); modelAndView.setView(redirectView); modelAndView.addAllObjects(new ParameterValueMapBuilder().build(parameterForm)); } parameterFormFormatter.format(parameterForm); modelAndView.addObject("reportName", reportName); return modelAndView; }