Why my onsubmitg is not firing - Spring

Posted by GigaPr on Stack Overflow See other posts from Stack Overflow or by GigaPr
Published on 2010-05-30T18:19:36Z Indexed on 2010/05/30 18:22 UTC
Read the original article Hit count: 175

Filed under:

Hi,

i have a controller

public class EditUserController  extends BaseController {

   public EditUserController() {
      setCommandClass(User.class);
      setCommandName("editaUser");
   }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

       ModelAndView modelAndView = new ModelAndView("editUser");
       String id = request.getParameter("id");
       if(!id.isEmpty())
       {
           User user = this.userServiceImplementation.get(Integer.parseInt(id));
           modelAndView.addObject("editaUser", user);
       }
       return modelAndView;
    }
}

and the view

<form:form method="POST" commandName="editaUser" cssClass="addUserForm">
                <div class="floatL">
                    <div class="padding5">
                        <div class="fieldContainer">
                            <strong>First Name:</strong>&nbsp;
                        </div>
                        <form:errors path="firstName" cssClass="error"/>
                        <form:input path="firstName" cssClass="textArea" />
                    </div>

                    <div class="padding5">
                        <div class="fieldContainer">
                            <strong>Last Name:</strong>&nbsp;
                        </div>
                        <form:errors path="lastName" cssClass="error"/>
                        <form:input path="lastName" cssClass="textArea"  />
                    </div>
                </div>

                <div class="floatR">
                   <div class="padding5">
                        <div class="fieldContainer">
                            <strong>Username:</strong>&nbsp;
                        </div>
                        <form:errors path="username" cssClass="error"/>
                        <form:input path="username" cssClass="textArea" />
                    </div>

                    <div class="padding5">
                        <div class="fieldContainer">
                            <strong>Password</strong>&nbsp;
                        </div>
                        <form:errors path="password" cssClass="error"/>
                        <form:input path="password" cssClass="textArea"/>
                    </div>
                </div>
                <input type="submit" class="floatR" value="Save" >
            </form:form>

and the bean definition looks like

<bean name="/editUser.htm" class="com.rssFeed.mvc.EditUserController">
       <property name="userServiceImplementation" ref="userServiceImplementation"/>
       <property name="commandName" value="editaUser" />
       <property name="successView" value="users"/>
       <property name="sessionForm" value="true"/>
  </bean>

I populate the view using the querystring but i would lke to update the record in the database on click of the submit button. i tried to insert a on submit method

protected ModelAndView onSubmit(Object command, BindException bindException) throws Exception {

      return new ModelAndView(getSuccessView());
   }

but it never fires

What is the problem i do not get it??

thanks

© Stack Overflow or respective owner

Related posts about spring-mvc