Announcement Announcement Module
Collapse
No announcement yet.
Validation Errors will not display Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validation Errors will not display

    I am having problems displaying validation errors on a JSP page. I successfully traverse my validator classes validate() method but the error messages are not displayed. I have set a default message as well as a specific message in messages.properties. I am beginning to think it may be a result of setting my form backing object to "registrationForm" instead of leaving it the default "command".

    Validate code snippet:
    Code:
    public void validate(Object command, Errors errors) {
    		RegistrationForm form = (RegistrationForm) command;
    		
    		LOG.debug("Registration Validator - validate()");
         
    		LOG.debug("Username "+form.getUserName()+" password "+form.getPassword());
    		if (form == null || form.getUserName().length() == 0 ) {     
    			errors.rejectValue("userName", "required", null, "Username Required");
               }
            
    		if (form == null || form.getPassword().length() == 0 ) {            
    			errors.rejectValue("password", "required", null, "Password Required");
               }
    	}
    JSP Form:

    Code:
    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    
    <link rel='stylesheet' type='text/css' href='../../../css/prototype1.css'/>
    
    <form method="post">
    
    <table border=0 width=100% cellspacing=0 cellpadding=2>
    <col align=left>
    <col align=left>
    
        <tr>
            <td colspan='2'>
            <h4><font color="#99999">Create Login</h4>
        </tr>
        <tr>
            <td colspan='2'>
        </tr>
         <tr> 
            <td colspan="1">Username&#58;</td>
            <td>
                <spring&#58;bind path="registrationForm.userName">
                    <input type="text" name="userName" value="<c&#58;out value="$&#123;status.value&#125;"/>" size="30">
                    <span class="error"><c&#58;out value="$&#123;status.errorMessage&#125;"/></span>
                </spring&#58;bind>
    	    </td>
        </tr>
        <tr> 
            <td colspan="1">Email Address&#58;</td>
            <td>
                <spring&#58;bind path="registrationForm.emailAddress">
                    <input type="text" name="emailAddress" value="<c&#58;out value="$&#123;status.value&#125;"/>" size="30">
                    <span class="error"><c&#58;out value="$&#123;status.errorMessage&#125;"/></span>
                </spring&#58;bind>
            </td>
        </tr>
        <tr> 
            <td colspan="1">Confirm Email&#58;</td>
            <td>
                <spring&#58;bind path="registrationForm.confirmEmailAddress">
                    <input type="text" name="confirmEmailAddress" value="<c&#58;out value="$&#123;status.value&#125;"/>" size="30">
                    <span class="error"><c&#58;out value="$&#123;status.errorMessage&#125;"/></span>
                </spring&#58;bind>
            </td>
        </tr>
        <tr> 
            <td colspan="1">Password&#58;</td>
            <td>
                <spring&#58;bind path="registrationForm.password">
                    <input type="password" name="password" value="<c&#58;out value="$&#123;status.value&#125;"/>" size="30">
                    <span class="error"><c&#58;out value="$&#123;status.errorMessage&#125;"/></span>
                </spring&#58;bind>
    	    </td>
        </tr>
         <tr> 
            <td colspan="1" rowspan="1"></td> 
            <td colspan="1">
                <input type="submit" value="Submit">
            </td>
        </tr>
    </table>
    </form>
    Messages.properties contains only:

    Code:
    required=This field cannot be empty
    Any suggestions? would be appreicated.

  • #2
    Ignore. I somehow deleted my include statement for my spring taglib.

    Comment

    Working...
    X