Announcement Announcement Module
Collapse
No announcement yet.
How to avoid validation call on form load? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to avoid validation call on form load?

    On loading of the jsp, spring validation errors are displayed.

    I would like to do the validation only on form submit.

    jsp is as follows

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    <%@ taglib prefix="spring" uri="/spring" %>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <body class='body'>


    <div id="addpanel" ><fieldset ><legend>Add new property</legend>
    <form name="frmaddpanel" method="POST">
    <p>
    <table border="1" cellpadding="2" cellspacing="2">
    <tr>
    <td >Name</td>
    <td>
    <spring:bind path="propertyForm.name">
    <input type="text" name="name" value="<c:out value="${status.value}"/>">
    </spring:bind>
    </td>
    </tr>
    <tr>
    <td >Description</td>
    <td>
    <spring:bind path="propertyForm.description">
    <input type="text" name="description" value="<c:out value="${status.value}"/>">
    </spring:bind>
    </td>
    </tr>
    </table>

    </p>
    <br>

    <spring:hasBindErrors name="propertyForm">
    <b><font color="red"> Please enter mandatory fields! </font></b>
    </spring:hasBindErrors>
    <br>
    <input type="submit" name="_save" value="Save" >
    <input type="submit" name="_cancel" value="Cancel">
    <input type="submit" name="_delete" value="Delete">

    </form>
    </div>
    </body>


    </html>

    Can anyone help me out.

    thanks

  • #2
    Form submission is determined by the implementation of:
    protected boolean isFormSubmission(HttpServletRequest request)

    ...by default a POST is treated as a form submission.

    Comment


    • #3
      Originally posted by katentim
      Form submission is determined by the implementation of:
      protected boolean isFormSubmission(HttpServletRequest request)

      ...by default a POST is treated as a form submission.
      thanks It is working fine Now.
      I do have one more query. On click of 'delete' button, validation code is calling. I would like to avoid 'validation calling' when delete button is clicked.

      Can you help me?

      Comment


      • #4
        On click of 'delete' button, validation code is calling. I would like to avoid 'validation calling' when delete button is clicked.
        This is probably happening because you are posting back to the controller. You can either hit a different URL and controller, or alter the workflow of the normal submission - for example check for a delete parameter in the request.

        Comment

        Working...
        X