Announcement Announcement Module
Collapse
No announcement yet.
OnSubmit method not returning correct View Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 01:46 PM.
Working...
X