Announcement Announcement Module
Collapse
No announcement yet.
How to implement reset button? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to implement reset button?

    Hi

    I'm using Spring 2.5.3.

    I want to implement a reset button to clear all the form fields. So I extends SimpleFormController and override processFormSubmission,

    Code:
    protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
       if (WebUtils.hasSubmitParameter(request, "reset")) {
          return new ModelAndView(getFormView());
       }
       return super.processFormSubmission(request, response, command, errors);
    }
    It looks like the problem occurs only when I returning the ModelAndView of the current view (getFormView()). The problem dissapeared when I returning another view.

    How do you implement a reset button?



    However, doing so will cause the following exception,

    Code:
    Method public org.springframework.web.servlet.support.BindStatus org.springframework.web.servlet.support.RequestContext.getBindStatus(java.lang.String) throws java.lang.IllegalStateException threw an exception when invoked on org.springframework.web.servlet.support.RequestContext@51630a with arguments of types [java.lang.String,]
    The problematic instruction:
    ----------
    ==> assignment: status=springMacroRequestContext.getBindStatus(path) [on line 120, column 9 in spring.ftl]
     in user-directive bind [on line 159, column 5 in spring.ftl]
     in user-directive spring.formInput [on line 9, column 11 in adduser.ftl]
    ----------
    
    Java backtrace for programmers:
    ----------
    freemarker.template.TemplateModelException: Method public org.springframework.web.servlet.support.BindStatus org.springframework.web.servlet.support.RequestContext.getBindStatus(java.lang.String) throws java.lang.IllegalStateException threw an exception when invoked on org.springframework.web.servlet.support.RequestContext@51630a with arguments of types [java.lang.String,]
    	at freemarker.ext.beans.OverloadedMethodModel.exec(OverloadedMethodModel.java:134)
    	at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
    	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
    	at freemarker.core.Assignment.accept(Assignment.java:90)

  • #2
    How about -

    <input type="reset" value="Reset!">

    in your form?

    Andy.

    Comment

    Working...
    X