views:

39

answers:

0

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());
   }

finally the BaseController class

public class BaseController extends SimpleFormController implements Controller {

   public UserServiceImplementation userServiceImplementation;

   public UserServiceImplementation getUserServiceImplementation() {
        return userServiceImplementation;
   }

   public void setUserServiceImplementation(UserServiceImplementation userServiceImplementation) {
        this.userServiceImplementation = userServiceImplementation;
   }

}

but it never fires

What is the problem i do not get it??

thanks