ActionErrors errors = null;
// execute validation
FormResult result = form.validate(request, inputs);
if (!result.isValid()) { // collect error messages
errors = new ActionErrors();
Messages messages = result.getMessages();
Iterator names = messages.getKeys();
while (names.hasNext()) {
String name = (String)names.next();
if (name != Messages.GLOBAL_KEY) {
Message message = messages.getFirstMessage(name);
ActionMessage error =
createActionMessage(request, locale, i18n, message);
errors.add(name, error);
} else {
Iterator iter = messages.getGlobalMessages();
while (iter.hasNext()) {
Message message = (Message)iter.next();
ActionMessage error =
createActionMessage(request, locale, i18n, message);
errors.add(ActionMessages.GLOBAL_MESSAGE, error);