List of usage examples for org.springframework.web.servlet ModelAndView setViewName
public void setViewName(@Nullable String viewName)
From source file:org.myjerry.evenstar.web.layout.LayoutController.java
public ModelAndView saveTemplate(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mav = new ModelAndView(); String blogID = request.getParameter("blogID"); String templateCode = request.getParameter("templateCode"); this.blogLayoutService.saveBlogTemplate(new Long(blogID), templateCode); mav.setViewName(".admin.layout"); mav.addObject("blogID", blogID); mav.addObject("templateCode", templateCode); return mav;/* w w w . jav a 2 s. c o m*/ }
From source file:per.mnn.controller.IndexController.java
@RequestMapping(value = "/index", method = RequestMethod.GET) public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse respond) { ModelAndView retval = new ModelAndView(); Session sess = HibernateUtil.getSessionFactory().openSession(); try {// w w w.j a v a2 s . co m Query q = sess.createQuery("FROM Category"); retval.addObject("categories", q.list()); } finally { sess.close(); } retval.setViewName("index"); return retval; }
From source file:com.klm.workshop.controller.AuthController.java
/** * Sign up client, and show the sign up form. On error, show errors. On * success, redirect to the sign in page and show success message. * // w w w . jav a2s. c o m * @param model Objects and view * @param account The posted account * @param result Binded validation * @param redirect The redirect attributes * @param locale The current client locale * @return Form to sign up, or a redirect (if client was sign up successfully) */ @RequestMapping(value = "/sign-up", method = RequestMethod.POST) public ModelAndView postCreate(ModelAndView model, @ModelAttribute("account") @Valid SignUpValidator account, BindingResult result, RedirectAttributes redirect, Locale locale) { if (result.hasErrors()) { model.setViewName("auth/sign_up"); } else { String password = PasswordHasher.hash(account.getPassword()); User user = new User(); user.setFirstName(account.getFirstName()); user.setLastName(account.getLastName()); user.setEmail(account.getEmail()); user.setPassword(password); user.setRole(User.Role.ROLE_PARTICIPANT); user.setEnabled(true); userDAO.create(user); String success = messageSource.getMessage("auth.message_sign_up_success", null, locale); redirect.addFlashAttribute("alertSuccess", success); model.setViewName("redirect:/auth/sign-in"); } return model; }
From source file:com.poscoict.license.web.controller.MorgueController.java
@RequestMapping(value = { "morgue" }, method = { RequestMethod.GET, RequestMethod.POST }) public ModelAndView morgue(HttpSession session) throws Exception { ModelAndView mv = new ModelAndView(); mv.setViewName("mainPage"); mv.addObject("page", "morgue/morgue"); mv.addObject("customBoardList", getMorgueService.getUerCustomBoardList((String) session.getAttribute("USER_NO"))); return mv;//from w w w. j a v a 2 s .c om }
From source file:de.fau.amos4.web.ClientController.java
@RequestMapping(value = "/client/profile") public ModelAndView ClientProfile(Principal principal) { ModelAndView mav = new ModelAndView(); final String currentUser = principal.getName(); Client client = clientService.getClientByEmail(currentUser); mav.addObject("Client", client); mav.setViewName("client/profile"); return mav;// www .j a va2 s . c o m }
From source file:co.com.soinsoftware.altablero.request.ClassRoomRequestHandler.java
private ModelAndView buildLinkStudentsToClassRoomPageModel(final UserBO logedUser, final Integer idGrade, final Integer idClassRoom, final boolean wasSaved, final boolean hasServerErrors) throws IOException { final ModelAndView model = this.buildModelAndView(logedUser); model.setViewName(CLASSROOM_LINK_MODEL); final String year = yearController.getLastYearString(); model.addObject(YEAR_PARAMETER, year); this.addGradeListToModel(model); this.addClassRoomListToModel(model, year, null, logedUser); this.addStudentsNotLinkedToModel(model, idGrade, idClassRoom, logedUser); final String currentYear = yearController.getCurrentYearString(); final int idSchool = this.getIdSchool(logedUser); model.addObject(CURRENT_CLASSROOM_LIST_PARAMETER, classRoomController.findClassRooms(currentYear, null, idSchool)); model.addObject(SAVED_PARAMETER, wasSaved); model.addObject(HAS_SERVER_ERRORS_PARAMETER, hasServerErrors); return model; }
From source file:com.poscoict.license.web.controller.MorgueController.java
@RequestMapping(value = { "customWriting" }, method = { RequestMethod.GET, RequestMethod.POST }) public ModelAndView customWritingForm(HttpSession session, @RequestParam(value = "boardId") String boardId) throws Exception { ModelAndView mv = new ModelAndView(); mv.setViewName("mainPage"); mv.addObject("page", "morgue/write"); mv.addObject("boardId", boardId); mv.addObject("boardName", getMorgueService.getCustomBoardName(boardId)); return mv;//from w ww . j av a 2 s . c o m }
From source file:com.poscoict.license.web.controller.MorgueController.java
@RequestMapping(value = { "cReplyList" }, method = RequestMethod.POST) public ModelAndView replyList(String boardId, String contentNo, HttpSession session) { ModelAndView mv = new ModelAndView(); mv.setViewName("morgue/replyList"); ArrayList<Map<String, Object>> list = getMorgueService.replyList(boardId, contentNo, session); mv.addObject("list", list); mv.addObject("size", list.size()); mv.addObject("replyBoardId", boardId); mv.addObject("contentNo", contentNo); return mv;/* ww w. j a v a 2 s. co m*/ }
From source file:ilearn.orb.controller.AnnotationController.java
@RequestMapping(value = "/annotation/{userid}", method = RequestMethod.GET) public ModelAndView textUserAnnotation(Locale locale, ModelMap modelMap, HttpServletRequest request, HttpSession session, @PathVariable("userid") Integer userid) { try {//from w ww . j av a 2s . co m request.setCharacterEncoding("UTF-8"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } txModule = new TextAnnotationModule(); ModelAndView model = new ModelAndView(); model.setViewName("annotation"); try { User[] students = null; UserProfile p = null; User selectedStudent = null; if (userid < 0) { students = HardcodedUsers.defaultStudents(); selectedStudent = selectedStudent(students, userid.intValue()); // p = HardcodedUsers.defaultProfile(selectedStudent.getId()); String json = UserServices .getDefaultProfile(HardcodedUsers.defaultProfileLanguage(selectedStudent.getId())); if (json != null) p = new Gson().fromJson(json, UserProfile.class); } else { Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer()) .setDateFormat(DateFormat.LONG).create(); String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()), session.getAttribute("auth").toString()); students = gson.fromJson(json, User[].class); selectedStudent = selectedStudent(students, userid.intValue()); json = UserServices.getJsonProfile(userid, session.getAttribute("auth").toString()); if (json != null) p = new Gson().fromJson(json, UserProfile.class); } modelMap.put("profileId", userid); modelMap.put("selectedStudent", selectedStudent); modelMap.put("students", students); modelMap.put("selectedProfile", p); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader .getResource("data/" + (selectedStudent.getLanguage().toLowerCase()) + ".json").getFile()); String js = LocalStorageTextFileHandler.loadFileAsString(file); Groups grps = new Gson().fromJson(js, Groups.class); modelMap.put("presents", grps); } catch (NumberFormatException e) { //e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return model; }