LazyFan
Jun 5th, 2006, 03:42 PM
Hi,
I am having a problem getting output from the hasBindErrors tag.
I have set up my validator class and all is well there. It idents the command object I am feeding it and pulls the data from it okay (which is tag binded from the same form controller).
And I have my LoginCommand object (which is custom extended from HashMap).
I have created some validation like so:
......
LoginCommand loginCommand = ( LoginCommand ) obj;
String strUserId = loginCommand.getUserId();
ValidationUtils.rejectIfEmpty( errors, "userId", "error.code",
"No entry found within the UserId field." );
if( !strUserId.equalsIgnoreCase( "admin" ) )
{
errors.rejectValue( "userId", "userId.Unknown", "User Id " + strUserId
+ " is invalid and unknown to the system." );
}
......
I have put some fast debug output out with:
System.out.println( ">>>> 1: " + errors.getAllErrors() );
System.out.println( ">>>> 2: " + errors.getObjectName());
This shows me the errors are being set-up correctly and do exist.
And my JSP code is like so:
<spring:hasBindErrors name="model.userId">
${errors.errorCount}
<c:out value="${errors}"/>
<c:out value="${errors.errorCount}"/>
<c:out value="${status.errorMessage}"/>
<c:out value="${status.errorMessages}"/>
</spring:hasBindErrors>
And I get nothing back.
I have also an entry in my messages.properties file like so:
userId.Unknown=Username not valid, try 'guest'
In my form controller I have a showForm which returns:
return new ModelAndView( getFormView(), "model", mapModel );
Could someone explain to me my flaw?
I am having a problem getting output from the hasBindErrors tag.
I have set up my validator class and all is well there. It idents the command object I am feeding it and pulls the data from it okay (which is tag binded from the same form controller).
And I have my LoginCommand object (which is custom extended from HashMap).
I have created some validation like so:
......
LoginCommand loginCommand = ( LoginCommand ) obj;
String strUserId = loginCommand.getUserId();
ValidationUtils.rejectIfEmpty( errors, "userId", "error.code",
"No entry found within the UserId field." );
if( !strUserId.equalsIgnoreCase( "admin" ) )
{
errors.rejectValue( "userId", "userId.Unknown", "User Id " + strUserId
+ " is invalid and unknown to the system." );
}
......
I have put some fast debug output out with:
System.out.println( ">>>> 1: " + errors.getAllErrors() );
System.out.println( ">>>> 2: " + errors.getObjectName());
This shows me the errors are being set-up correctly and do exist.
And my JSP code is like so:
<spring:hasBindErrors name="model.userId">
${errors.errorCount}
<c:out value="${errors}"/>
<c:out value="${errors.errorCount}"/>
<c:out value="${status.errorMessage}"/>
<c:out value="${status.errorMessages}"/>
</spring:hasBindErrors>
And I get nothing back.
I have also an entry in my messages.properties file like so:
userId.Unknown=Username not valid, try 'guest'
In my form controller I have a showForm which returns:
return new ModelAndView( getFormView(), "model", mapModel );
Could someone explain to me my flaw?