2

I have the following form:

<form:form method="POST" action="signin.dlp" commandName="user" >
<form:input path="useremail" id="useremail" /><FONT color="red"><form:errors path="useremail" /></FONT><Br />
<form:password path="pswd" id="pswd" /><FONT color="red"><form:errors path="pswd" /></FONT> <br />
<input id ="login" type="submit" value="Login"></input>                                 
</form:form>

and then I i have Validator which validates value from and send error.

what I would like to do is to add extra error label, for example

<form:errors path="generarError" />

and inside my validator I can do the following:

if (user.getA().equals(user.getB()))
 errors.rejectValue("generarError",
                "lengthOfUser.user.generarError",
                "A is not equeal to B. Sorry");
          }

The important thing that I generalError is not member of user object.

How can I do that?

1 Answer 1

3

I guess you cannot bind an error to the nonexistent field.

However, if you want to show an error that belongs to the form as a whole rather then to one of its fields, you can do the following:

<form:errors /> 

.

errors.reject("lengthOfUser.user.generarError",  "A is not equeal to B. Sorry");  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.