Results 1 to 1 of 1

Thread: OnSubmit method not returning correct View

Threaded View

  1. #1
    Join Date
    Mar 2011
    Posts
    7

    Default OnSubmit method not returning correct View

    Having an issue with a controller not returning the correct view. Instead, it just goes back to the original view.

    Here is the handleRequest:

    Code:
    public ModelAndView handleRequest(HttpServletRequest request,
    			HttpServletResponse response) throws ServletException, IOException {
    	
    		try {
    			super.handleRequest(request, response);
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		
    	
    		//CREATING MAP AND POPULATING IT
    		
    		
    
    		ModelAndView mav = new ModelAndView("login/login_test");
    		mav.addObject("model", myMap);
    		
    		return mav;
    
    	}
    Everything here works correctly, no issues.

    Here is the onSubmit method:

    Code:
    protected ModelAndView onSubmit(Object command) throws ServletException {
    
    	
    		
    		String name = ((Login) command).getName();
    		String password = ((Login) command).getPassword();
    
    		// VARIOUS OPERATIONS, GETTING PERM NUMBER
            
    		// checking the username and password and setting the permission
    		if (perm != 0) {
      
    		       // VARIOUS OPERATIONS, SETTING USER PERMISSION AND NAME
    			if (perm == 6)
    				return new ModelAndView(getSuccessView(),myModel);
    			else if (perm == 5)
    				return new ModelAndView("scriptmenu", "model", myModel);
    			else
    				return new ModelAndView("hello", "model", myModel);
    		} else {
    
    		        return new ModelAndView("incorrect", "model", myModel); 
    
    		}
    
    }
    Everything works correctly, user gets set and permissions are set. The problem is that it does not move to the Success View or the incorrect view, but instead always stays on the same view, no matter the if the password is correct or not.

    Here is the bean:

    Code:
     <bean name="/logintest.htm" class="storeapp.web.LoginTestController" scope="prototype">
            <property name="sessionForm" value="true"/>
            <property name="commandName" value="login"/>
            <property name="commandClass" value="storeapp.service.Login"/>
            <property name="formView" value="login"/>  
            <property name="successView" value="tsemenu.htm"/>
            <property name="userManager" ref="userManager"/>
            <property name="scriptManager" ref="scriptManager"/>
     </bean>
    Any help is greatly appreciated, thanks!
    Last edited by rufu; May 1st, 2012 at 01:46 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •