Code example for ModelAndView

Methods: addObjectsetViewName

0
	 
	@RequestMapping(value="/submitCredentials") 
	public ModelAndView setupToodledo(HttpServletRequest request, HttpServletResponse response)
		throws RateLimitReachedException, ExceptionModelAndView mav = new ModelAndView();
		String email = request.getParameter("username");
		String password = request.getParameter("password");
		email = email.trim();
		password = password.trim();
		request.setAttribute("username", email);
		List<String> required = new ArrayList<String>();
		if (email.equals(""))
			required.add("username");
		if (password.equals(""))
			required.add("password");
		if (required.size()!=0) {
			mav.setViewName("connectors/toodledo/enterCredentials");
			mav.addObject("required", required);
			return mav;
		} 
		Long guestId = getGuestId();
		String userid = updater.getToodledoUserid(guestId, Connector.getConnector("toodledo"), email, password);
		 
		if (userid==null) {
			mav.setViewName("connectors/toodledo/error");
			return mav;
		} 
 
        final Connector connector = Connector.getConnector("toodledo");
        final ApiKey apiKey = guestService.createApiKey(guestId, connector);
 
		guestService.setApiKeyAttribute(apiKey, "email", email);
		guestService.setApiKeyAttribute(apiKey, "password", password);
		guestService.setApiKeyAttribute(apiKey, "userid", userid);
		 
		mav.setViewName("connectors/toodledo/success");
		return mav;
	} 
 
	public static long getGuestId() { 
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
Contextual code suggestions in your IDE  Get Codota for Java