I use SpringMVC in my webapp to process forms and validate them.
In my validator, I have this code:
@Override
public void validate(final Object target, final Errors errors)
{
final LoginCommand loginCommand = (LoginCommand) target;
if (checkCredentials(loginCommand.getLogin(), loginCommand.getPassword()) {
errors.rejectValue("login", "login.error.invalid");
errors.rejectValue("password", "login.error.invalid");
}
This way I get the correctly displayed invalid when populating the cssErrorClass attribute. The problem is that the login.error.invalid message is in the list of error messages that I will display twice.
What is the best way to mark two input fields invalid, but there is only one message in the error list? I went through all the SpringMVC / api documentation and did not find a way to reject the field without providing a message.
source
share