Announcement Announcement Module
Collapse
No announcement yet.
SuccessView problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SuccessView problem

    Hi,

    I am currently developing a web based application and am working on the login functionality at the moment. Is there any way I can leave the successView property out of my servlet.xml file? as on a successful login there may not be just 1 success view, depending on the user who has logged in.

    Furthermore for some reason in my UserLoginController class which extends SimpleFormController, the onSubmit method doesnt get called at all for some reason. The code below is my onSubmit method:

    public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception
    {
    User user = (User)command;
    if(user.getUsername() == null && user.getPassword() == null)
    {
    return new ModelAndView("userLogin", "incorrectLogin", "false");
    }

    else
    {
    User loggedInUser = userdao.getUser(user.getUsername(), user.getPassword());

    if(loggedInUser.getUsername() != null && loggedInUser.getPassword() != null && loggedInUser.getUsertype().equals("Administrator") )
    {
    //request.getSession().setAttribute("loggedInUser", loggedInUser);
    return newModelAndView("adminLoginSuccess", "loggedInUser", loggedInUser);
    }
    }
    }

    would anyone be able to tell my where i am going wrong

    regards

  • #2
    Some ideas

    Originally posted by cajchris
    Is there any way I can leave the successView property out of my servlet.xml file? as on a successful login there may not be just 1 success view, depending on the user who has logged in.
    Nothing forces you to inject the success view via the XML config file. Your controller can use whatever logic it likes to determine the success view - just return the appropriate ModelAndView from your onSubmit() method.

    Originally posted by cajchris
    ... in my UserLoginController class which extends SimpleFormController, the onSubmit method doesnt get called at all for some reason.
    If onSubmit's not being called, it's usually because binding or validation has failed, or because the controller doesn't think the request is a form submission (e.g. it might be a form change request, although not likely in your case). So my suggestions are:
    1. read the JavaDoc for SimpleFormController in order to understand its workflow, and
    2. enable debug-level logging for Spring's MVC code, to see what binding/validation errors are happening.
    HTH,

    Comment


    • #3
      regarding the successView issue, if i leave that property out of the servlet.xml for the form controller bean then an error is thrown in the browser saying that the successView hasnt been set, so it seems as if it is forcing me to enter it.

      Comment


      • #4
        What does your controller look like?

        Originally posted by cajchris
        regarding the successView issue, if i leave that property out of the servlet.xml for the form controller bean then an error is thrown in the browser saying that the successView hasnt been set, so it seems as if it is forcing me to enter it.
        Are you talking about your UserLoginController class? Could you post the code for it here please?

        P.S. When posting code to the forum, don't forget to wrap it in [ CODE] [/ CODE] tags (without the spaces); makes it more readable, and stops valid code turning into smilies, etc!

        Comment

        Working...
        X