List of usage examples for org.springframework.web.servlet ModelAndView setViewName
public void setViewName(@Nullable String viewName)
From source file:com.ut.healthelink.controller.newsArticleController.java
/** * The '/create' POST request will submit the new article once all required fields are checked. * * @param newsArticle The object holding the news article form fields * @param result The validation result * @param redirectAttr The variable that will hold values that can be read after the redirect * @param action The variable that holds which button was pressed * * @return Will return the news article list page on "Save" * @throws Exception/* w ww . j a va 2 s. c om*/ */ @RequestMapping(value = "/create", method = RequestMethod.POST) public ModelAndView saveNewArticle(@Valid newsArticle newsArticle, BindingResult result, RedirectAttributes redirectAttr, @RequestParam String action) throws Exception { if (result.hasErrors()) { ModelAndView mav = new ModelAndView(); mav.setViewName("/administrator/sysadmin/news/details"); return mav; } newsarticlemanager.createNewsArticle(newsArticle); redirectAttr.addFlashAttribute("savedStatus", "created"); ModelAndView mav = new ModelAndView(new RedirectView("/administrator/sysadmin/news")); return mav; }
From source file:com.ut.healthelink.controller.newsArticleController.java
/** * The '/edit' POST request will submit the new article once all required fields are checked. * * @param newsArticle The object holding the news article form fields * @param result The validation result * @param redirectAttr The variable that will hold values that can be read after the redirect * @param action The variable that holds which button was pressed * * @return Will return the news article list page on "Save" * @throws Exception// w w w.java2 s . co m */ @RequestMapping(value = "/edit", method = RequestMethod.POST) public ModelAndView saveArticleUpdates(@Valid newsArticle newsArticle, BindingResult result, RedirectAttributes redirectAttr, @RequestParam String action) throws Exception { if (result.hasErrors()) { ModelAndView mav = new ModelAndView(); mav.setViewName("/administrator/sysadmin/news/details"); return mav; } newsarticlemanager.updateNewsArticle(newsArticle); redirectAttr.addFlashAttribute("savedStatus", "updated"); ModelAndView mav = new ModelAndView(new RedirectView("/administrator/sysadmin/news")); return mav; }
From source file:hbaseweb.controllers.DefaultController.java
@RequestMapping(value = "/", method = RequestMethod.GET) public ModelAndView index(@RequestParam(value = "tablename", required = false) String tablename, @RequestParam(value = "page", required = false) String page, ModelMap map) { String test = "valod"; map.put("test", test); map.put("testBytes", Bytes.toBytes(test)); map.put("tablename", tablename); map.put("page", page); int ipage = 1; try {// w ww . j a v a2 s . c o m ipage = Integer.parseInt(page); } catch (Exception e) { ipage = 1; } try { Configuration config = HBaseConfiguration.create(); config.clear(); config.set("hbase.zookeeper.quorum", "nn1.netangels.net,nn2.netangels.net,rm1.netangels.net"); config.set("hbase.zookeeper.property.clientPort", "2181"); HBaseAdmin.checkHBaseAvailable(config); System.out.println("HBase is running!"); Connection connection = ConnectionFactory.createConnection(config); Admin admin = connection.getAdmin(); HTableDescriptor[] tables = admin.listTables(); map.put("tables", tables); if (tablename != "" & tablename != null) { TableName tableName = TableName.valueOf(tablename); if (admin.tableExists(tableName)) { // HTable table = new HTable(config, tablename); Table table = connection.getTable(tableName); // aa = table.getTableDescriptor().getFamilies(); System.out.println(tablename); byte[] POSTFIX = new byte[] { 0x00 }; Filter filter = new PageFilter(50); int totalRows = 0; lastrow = null; Scan scan = new Scan(); scan.setFilter(filter); // byte[] rowPrefix = Hex.decodeHex("000001000004000004000001000001000005000005000002000002000003000003".toCharArray()); // scan.setRowPrefixFilter(rowPrefix); for (int i = 1; i <= ipage; i++) { if (lastrow != null) { byte[] startRow = Bytes.add(lastrow, POSTFIX); System.out.println("start row: " + Bytes.toStringBinary(startRow)); scan.setStartRow(startRow); } // scan.setStopRow(Bytes.toBytes(2)); ResultScanner results2 = table.getScanner(scan); for (Result result = results2.next(); result != null; result = results2.next()) { lastrow = result.getRow(); totalRows++; } } ResultScanner results = table.getScanner(scan); Result[] values = results.next(50); results.close(); table.close(); map.put("values", values); } } } catch (Exception ce) { ce.printStackTrace(); } // map.put("msg", "Hello Spring 4 Web MVC!"); ModelAndView mav = new ModelAndView(); mav.setViewName("index"); return mav; // return "index"; }
From source file:com.klm.workshop.controller.participant.TargetBehaviorController.java
/** * Show panel with verbs for the "Define Target Behavior" part * /*from w w w . j ava 2 s . com*/ * @param model Objects and view * @return Panel with the verbs for selecting the Target Behavior */ @RequestMapping(value = "/index", method = RequestMethod.GET) public ModelAndView index(ModelAndView model) { model.addObject("workshopStep", CURRENT_STEP); model.addObject("verbs", getVerbsForCurrentSession()); model.setViewName(VIEW_FOLDER + "/index"); return model; }
From source file:io.uengine.web.system.UserController.java
/** * ? ??? ? ??? .//from w ww . java2 s .co m */ @RequestMapping(value = "/sendPasswd", method = RequestMethod.POST) public ModelAndView registerRequest(@RequestParam String email) { try { //? if (userService.getUser(email) == null) { ModelAndView mav = new ModelAndView(); mav.setViewName("/auth/sendPasswdFail"); mav.addObject("responseEmail", email); return mav; } //? ? ? ?? ??. userService.sendPasswdMail(email); ModelAndView mav = new ModelAndView(); mav.setViewName("/auth/sendPasswdSuccess"); return mav; } catch (Exception ex) { ModelAndView mav = new ModelAndView(); mav.setViewName("/auth/sendPasswdFail"); mav.addObject("responseEmail", email); return mav; } }
From source file:com.klm.workshop.controller.AuthController.java
/** * Lets anonymous clients sign in// www . ja va2 s . co m * * @param model Autowired model and view * @param error Login error cause * @return Sign in view with the sign in error, if set */ @RequestMapping(value = "/sign-in", method = RequestMethod.GET) public ModelAndView getSignIn(ModelAndView model, @RequestParam(value = "error", required = false, defaultValue = "") String error) { model.setViewName("auth/sign_in"); model.getModelMap().addAttribute("error", error); model.getModelMap().addAttribute("user", new User()); return model; }
From source file:com.rr.wabshs.ui.dashboard.dashboardController.java
/** * The 'getUpcomingEvents.do' GET request will return the table view for any upcoming events. * @return/*from w ww. j a v a2 s. c o m*/ * @throws Exception */ @RequestMapping(value = "/getUpcomingEvents.do", method = RequestMethod.GET) public @ResponseBody ModelAndView upcomingEvents(HttpSession session, @RequestParam(value = "eventCategory", required = false) String eventCategory) throws Exception { ModelAndView mav = new ModelAndView(); mav.setViewName("/dashboard/widgets/events/inc_upcomingEvents"); /* Get a list of completed surveys the logged in user has access to */ User userDetails = (User) session.getAttribute("userDetails"); Calendar today = Calendar.getInstance(); String from = new SimpleDateFormat("yyyy-MM-dd").format(today.getTime()); today.add(Calendar.MONTH, 3); String to = new SimpleDateFormat("yyyy-MM-dd").format(today.getTime()); /* Get Gender Values */ List<calendarEvents> upcomingEvents = calendarmanager.getEvents(programId, from, to, eventCategory, userDetails); if (upcomingEvents != null && upcomingEvents.size() > 0) { calendarEventTypes eventTypeObject; for (calendarEvents event : upcomingEvents) { eventTypeObject = calendarmanager.getEventType(event.getEventTypeId()); event.setEventColor(eventTypeObject.getEventTypeColor()); } } mav.addObject("upcomingEvents", upcomingEvents); return mav; }
From source file:com.rr.wabshs.ui.resources.resourcesController.java
/** * The 'getResourceList' GET request will return the list of available resources. * @param session/*from w w w . java 2 s . c o m*/ * @return * @throws Exception */ @RequestMapping(value = "/getResourceList", method = RequestMethod.GET) @ResponseBody public ModelAndView getResourceList(HttpSession session) throws Exception { ModelAndView mav = new ModelAndView(); mav.setViewName("/resources/resourceList"); /* Get a list of available program resources */ List<programResources> programResources = resourceManager.getResources(programId); mav.addObject("programResources", programResources); return mav; }
From source file:ilearn.orb.controller.ProfilesController.java
@RequestMapping(value = "/profiles/{userid}", method = RequestMethod.GET) public ModelAndView userProfile(Locale locale, @PathVariable("userid") Integer userid, ModelMap modelMap, HttpSession session) {//from w w w . ja v a2 s . c o m ModelAndView model = new ModelAndView(); model.setViewName("profiles"); try { String json; 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()); json = UserServices.getDefaultProfile(HardcodedUsers.defaultProfileLanguage(userid)); 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(); 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); } String dataForCircles = ""; if (p != null) { String categories = "["; dataForCircles = "["; ProblemDescription probs[][] = p.getUserProblems().getProblems().getProblems(); for (int i = 0; i < probs.length; i++) { for (int j = 0; j < probs[i].length; j++) { dataForCircles = dataForCircles + "[" + i + ", " + p.getUserProblems().getUserSeverity(i, j) + ",\"" + probs[i][j].getHumanReadableDescription() + "\"]"; if (i != probs.length - 1 || j != probs[i].length - 1) dataForCircles = dataForCircles + ", "; } categories = categories + "\"" + p.getUserProblems().getProblemDefinition(i).getUri() + "\""; if (i != probs.length - 1) categories = categories + ", "; } categories = categories + "]"; dataForCircles = dataForCircles + "], " + categories + ", " + probs.length + ", \"" + p.getLanguage() + "\""; } modelMap.put("selectedStudent", selectedStudent); modelMap.put("students", students); modelMap.put("selectedProfile", p); modelMap.put("dataForCircles", dataForCircles); } catch (NumberFormatException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return model; }
From source file:com.javacodegags.waterflooding.controller.AdminController.java
@RequestMapping(value = "/admin") public ModelAndView admin(HttpServletResponse response) throws IOException { ModelAndView mav = new ModelAndView(); mav.setViewName("admin"); return mav;// ww w. j ava2 s. c o m }