Spring Framework ModelAndView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ModelAndView class.

This code example shows how to use the following methods:addAllObjects, setView, setViewName
					return null; 
				} 
			} 
		} 
 
		ModelAndView modelAndView = new ModelAndView(); 
		modelAndView.addAllObjects(RequestContextUtils.getInputFlashMap(request)); 
 
		if (getViewName() != null) { 
			modelAndView.setViewName(viewName); 
		} 
		else { 
			modelAndView.setView(getView()); 
		} 
 
		return (isStatusOnly() ? null : modelAndView); 
	} 
 
} 
8
CodeRank
This code example shows how to use the following methods:addAllObjects, addObject, setView, setViewName
 
        map.put("artist", request.getParameter("artist")); 
        map.put("song", request.getParameter("song")); 
 
        ModelAndView result = super.handleRequestInternal(request, response); 
        result.addObject("model", map); 
        return result; 
    } 
} 

8
CodeRank
This code example shows how to use the following methods:addObject
    @Autowired 
    ConfigurationServiceFacade configurationServiceFacade;
 
    @RequestMapping("restApprovalList.ftl") 
    public ModelAndView list() {
        ModelAndView mav = new ModelAndView("approval/list");
        List<BreadCrumbsLinks> breadcrumbs = new AdminBreadcrumbBuilder().withLink("View REST Approval List", "").build();
        mav.addObject("isApprovalRequired", RESTConfigKey.isApprovalRequired(configurationServiceFacade));
        mav.addObject("breadcrumbs", breadcrumbs);
        mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
        mav.addObject("approvedList", approvalService.getAllNotWaiting());
        return mav;
    } 
 
    @RequestMapping("restApproval/id-{id}/details.ftl") 
    public ModelAndView details(@PathVariable Long id) {
        ModelAndView mav = new ModelAndView("approval/details");
        mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
        RESTApprovalEntity approval = approvalService.getDetails(id);
        mav.addObject("approval", approval);
7
CodeRank
This code example shows how to use the following methods:addObject, setViewName
        } 
 
        String requestUri = request.getRequestURI();
        logger.error("Uncaught exception while accessing '" + requestUri + "'", cause);
 
        ModelAndView mm = new ModelAndView();
        mm.setViewName("uncaughtException");
        mm.addObject("uncaughtException", cause);
        mm.addObject("requestUri", requestUri);
        if (cause != null) {
            Writer result = new StringWriter();
            cause.printStackTrace(new PrintWriter(result));
            mm.addObject("stackString", result.toString());
        } 
        return mm;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addAllObjects, addObject, setView, setViewName
            uploadDirectory = new File(musicFolders.get(0).getPath(), "Incoming").getPath(); 
        } 
 
        Player player = playerService.getPlayer(request, response); 
        ModelAndView result = super.handleRequestInternal(request, response); 
        result.addObject("model", map); 
        map.put("user", securityService.getCurrentUser(request)); 
        map.put("uploadDirectory", uploadDirectory); 
        map.put("genres", mediaFileService.getGenres()); 
        map.put("currentYear", Calendar.getInstance().get(Calendar.YEAR)); 
        map.put("musicFolders", settingsService.getAllMusicFolders()); 
        map.put("clientSidePlaylist", player.isExternalWithPlaylist() || player.isWeb()); 
        map.put("brand", settingsService.getBrand()); 
        return result; 
    } 
 
    public void setSettingsService(SettingsService settingsService) { 
        this.settingsService = settingsService; 
    } 
 

7
CodeRank
This code example shows how to use the following methods:addObject
    } 
 
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView handleRequestInternal(@RequestParam(value = "globalPrdCategoryNum", required = true) String globalPrdCategoryNum) {
 
        ModelAndView modelAndView = new ModelAndView("viewProductCategoryDetails");
        List<ProductCategoryTypeDto> typeDto = adminServiceFacade.retrieveProductCategoryTypes();
        ProductCategoryDetailsDto detailsDto =  adminServiceFacade.retrieveProductCateogry(globalPrdCategoryNum);
        modelAndView.addObject("typeDto", typeDto);
        modelAndView.addObject("detailsDto", detailsDto);
        modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("viewProductCategoryDetails", "viewProductCategoryDetails.ftl").build());
        modelAndView.addObject("globalPrdCategoryNum", globalPrdCategoryNum);
        return modelAndView;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addObject
	    List<Supervisor> directReports = userManager.getEmployees(personId).getSupervisorList(); 
	     
 
	     
	     
		ModelAndView mav = new ModelAndView(view); 
		mav.addObject("userData", userData); 
		mav.addObject("org", org); 
		mav.addObject("directReports", directReports); 
		mav.addObject("supervisor", supervisors); 
		 
		return mav; 
		 
	} 
 
	public String getView() { 
		return view; 
	} 
 
	public void setView(String view) { 
7
CodeRank
This code example shows how to use the following methods:getModel, getViewName
	@Test 
	public void handleRequestWithViewName() throws Exception { 
		String viewName = "testView"; 
		this.controller.setViewName(viewName); 
		ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); 
		assertEquals(viewName, mav.getViewName()); 
		assertTrue(mav.getModel().isEmpty()); 
	} 
 
	@Test 
	public void handleRequestWithoutViewName() throws Exception { 
		ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); 
		assertNull(mav.getViewName()); 
		assertTrue(mav.getModel().isEmpty()); 
	} 
 
	@Test 
	public void handleRequestWithFlashAttributes() throws Exception { 
		this.request.setAttribute(DispatcherServlet.INPUT_FLASH_MAP_ATTRIBUTE, new ModelMap("name", "value")); 
		ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); 
7
CodeRank
This code example shows how to use the following methods:getModelMap, wasCleared
	@Override 
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) 
			throws Exception { 
 
		this.requestInterceptor.postHandle(new DispatcherServletWebRequest(request, response), 
				(modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null)); 
	} 
 
	@Override 
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) 
			throws Exception { 
 
		this.requestInterceptor.afterCompletion(new DispatcherServletWebRequest(request, response), ex); 
	} 
 
	@Override 
	public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) { 
		if (this.requestInterceptor instanceof AsyncWebRequestInterceptor) { 
			AsyncWebRequestInterceptor asyncInterceptor = (AsyncWebRequestInterceptor) this.requestInterceptor; 
			DispatcherServletWebRequest webRequest = new DispatcherServletWebRequest(request, response); 
7
CodeRank
This code example shows how to use the following methods:addObject
     
    private final SitePreferenceHelper sitePreferenceHelper = new SitePreferenceHelper();
     
    @RequestMapping(value = "/viewSavingsAccountDetails", method=RequestMethod.GET)
    public ModelAndView showSavingsAccountDetails(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView modelAndView =new ModelAndView();
        sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountDetails", request);
        modelAndView.addObject("include_page", new IncludePage(request, response));
         
        String globalAccountNum = request.getParameter("globalAccountNum");
         
        SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
        modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
         
        boolean containsQGForCloseSavings = false;
        containsQGForCloseSavings = questionnaireServiceFacade.getQuestionGroupInstances(savingsAccountDetailDto.getAccountId(), "Close", "Savings").size() > 0;
        modelAndView.addObject("containsQGForCloseSavings", containsQGForCloseSavings);
         
        modelAndView.addObject("backPageUrl", UrlHelper.constructCurrentPageUrl(request));
         

7
CodeRank
See Code Examples for Spring Framework ModelAndView Methods: