List of usage examples for org.springframework.web.servlet ModelAndView addObject
public ModelAndView addObject(String attributeName, @Nullable Object attributeValue)
From source file:com.leapfrog.academyspring.controller.CourseController.java
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public ModelAndView edit(@PathVariable("id") int id) { ModelAndView mv = new ModelAndView("course/editcourse"); mv.addObject("Course", courseService.getById(id)); return mv;//from www . j av a 2 s . c om }
From source file:com.mycompany.springmvcaccount.controller.UserFormController.java
@RequestMapping(value = "/registerForm") public ModelAndView showFormRegister() { ModelAndView mv = new ModelAndView(); mv.setViewName("registerBootstrap"); mv.addObject("user", new User()); mv.addObject("countries", countries); return mv;//from ww w . j av a2 s . c om }
From source file:controllers.CircleController.java
@RequestMapping(value = "/viewcircle={id}", method = RequestMethod.GET) public ModelAndView circle(@PathVariable("id") int id, ModelAndView mv) { ModelAndView newmv = new ModelAndView("circle"); newmv.addObject("Circle", circleDAO.getCircle(id)); this.id = id; return newmv; }
From source file:cz.muni.fi.mir.tools.CustomPageInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (modelAndView != null) { modelAndView.addObject("gitPropertiesModel", gitPropertiesModel); }/*from w w w. j a v a 2 s . c o m*/ }
From source file:gov.nih.nci.calims2.ui.generic.crud.SubFlowReturnTester.java
/** * Test the controller doReturnFromFlow method. * /*from w w w . ja v a 2 s. co m*/ * @throws Exception if an exception occurs */ @SuppressWarnings("unchecked") @Test public void testDoReturnFromFlow() throws Exception { Class<T> controllerClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()) .getActualTypeArguments()[0]; T controller = controllerClass.newInstance(); ModelAndView model = new ModelAndView(); model.addObject("form", controller.createForm()); controller.doReturnFromFlow(model, subFlowId, 1L); Object property = PropertyUtils.getProperty(((CRUDForm) model.getModel().get("form")).getEntity(), propertyName); if (collection) { CRUDAssert.assertSubFlowEntities((Collection<EntityWithId>) property, 1L); } else { CRUDAssert.assertSubFlowEntity((EntityWithId) property, 1L); } }
From source file:com.castlemock.web.basis.web.mvc.controller.user.CurrentUserController.java
/** * The service provides the functionality to retrieve information about the user that is currently logged in. * The user will be able to both view their information, but also update their information through the page. * @return A view that displays information about the user being currently logged in *//* w ww . ja v a2 s . co m*/ @PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(method = RequestMethod.GET) public ModelAndView defaultPage() { final String loggedInUsername = getLoggedInUsername(); final ReadUserByUsernameOutput readUserByUsernameOutput = serviceProcessor .process(new ReadUserByUsernameInput(loggedInUsername)); final UserDto userDto = readUserByUsernameOutput.getUser(); final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(USER, userDto); return model; }
From source file:com.mc.controller.HelloController.java
@RequestMapping("/welcome/{countryName}/{userName}") public ModelAndView helloWorld(@PathVariable Map<String, String> pathVars) { String name = pathVars.get("userName"); String country = pathVars.get("countryName"); ModelAndView model = new ModelAndView("index"); model.addObject("welcomeMessage", "hello " + name + ". You are from " + country); return model; }
From source file:io.springagora.store.web.controllers.ProductWebController.java
@RequestMapping(value = "/showcase", method = RequestMethod.GET) public ModelAndView showcaseProducts() { ModelAndView mav = new ModelAndView("productShowcase"); mav.addObject("categories", Category.findAll()); mav.addObject("products", Product.findForShowcase(0, 20).getContent()); return mav;// www . j a v a2s .com }
From source file:org.opensafety.hishare.controller.AddAuthenticationServerController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView authenticateUser(@RequestParam("authenticationServerName") String authenticationServerName, @RequestParam("authenticationServerPassword") String authenticationServerPassword) { //*/* w w w . j ava2s .co m*/ ModelAndView mav = new ModelAndView("outputString"); mav.addObject("string", "This functionality is disabled"); return mav; //*/ /* ModelAndView mav; String successMessage = addAuthenticationServer.addAuthenticationServer(authenticationServerName, authenticationServerPassword); mav = new ModelAndView("outputString"); mav.addObject("string", successMessage); return mav; //*/ }
From source file:cn.newgxu.lab.core.controller.GlobalExceptionHandler.java
/** * ??ajaxhtml~//from w w w. j av a2 s.com * @param t ? * @return json or html depends on what the client wants! */ @ExceptionHandler(Throwable.class) public ModelAndView exp(Throwable t) { L.error("?", t); ModelAndView mav = new ModelAndView(ERROR_PAGE); mav.addObject(AJAX_STATUS, "no"); mav.addObject(AJAX_MESSAGE, t.getMessage()); if (t.getCause() != null) { mav.addObject(EXP_REASON, t.getCause().getMessage()); } else { mav.addObject(EXP_REASON, UNKNOWN_REASON); } return mav; }