String attributeValue = element.getAttributeValue(attributeName);
BindStatus bindStatus = FieldUtils.getBindStatus(arguments.getConfiguration(), arguments, attributeValue);
if (bindStatus.isError()) {
EntityForm form = (EntityForm) ((BindingResult)bindStatus.getErrors()).getTarget();
// Map of tab name -> (Map field Name -> list of error messages)
Map<String, Map<String, List<String>>> result = new HashMap<String, Map<String, List<String>>>();
for (FieldError err : bindStatus.getErrors().getFieldErrors()) {
//attempt to look up which tab the field error is on. If it can't be found, just use
//the default tab for the group
String tabName = EntityForm.DEFAULT_TAB_NAME;
Tab tab = form.findTabForField(err.getField());
if (tab != null) {
tabName = tab.getTitle();
}
Map<String, List<String>> tabErrors = result.get(tabName);
if (tabErrors == null) {
tabErrors = new HashMap<String, List<String>>();
result.put(tabName, tabErrors);
}
if (err.getField().contains(DynamicEntityFormInfo.FIELD_SEPARATOR)) {
//at this point the field name actually occurs within some array syntax
String fieldName = err.getField().substring(err.getField().indexOf('[') + 1, err.getField().lastIndexOf(']'));
String[] fieldInfo = fieldName.split("\\" + DynamicEntityFormInfo.FIELD_SEPARATOR);
Field formField = form.getDynamicForm(fieldInfo[0]).getFields().get(fieldName);
if (formField != null) {
addFieldError(formField.getFriendlyName(), err.getCode(), tabErrors);
} else {
LOG.warn("Could not find field " + fieldName + " within the dynamic form " + fieldInfo[0]);
addFieldError(fieldName, err.getCode(), tabErrors);
}
} else {
Field formField = form.findField(err.getField());
if (formField != null) {
addFieldError(formField.getFriendlyName(), err.getCode(), tabErrors);
} else {
LOG.warn("Could not field field " + err.getField() + " within the main form");
addFieldError(err.getField(), err.getCode(), tabErrors);