I see two possibilities to solve this problem -
a) Implement a seperate command object with the two password fields and map this manually to and from your business object, as you said
b) override the onBindAndValidate() method in your controller (that should have SimpleFormController extended) and access the password fields via the HttpServletRequest object - example:
Code:
@Override
protected void onBindAndValidate(final HttpServletRequest request, final Object command, final BindException errors)
throws Exception
{
final YourCommandClass myCommand = (YourCommandClass)command;
final String passwordA = RequestUtils.getStringParameter(request, "passworda", "");
final String passwordB = RequestUtils.getStringParameter(request, "passwordb", "");
if (!passwordA.equals(passwordB))
{
errors.rejectValue("passwordA", null, "Passwords doesn't match");
}
else
{
myCommand.setPassword(passwordA);
}
}
HTH
Oliver