Everything worked properly with the DataBinder and the PropertyEditor wasn't changed, so I don't think it can be a typo. The problem occurs since we are using the BeanWrapperImpl to convert the value manually.
The PropertyEditor code:
Code:
final class MaterialTypeSetPropertyEditor extends PropertyEditorSupport {
/**
* {@inheritDoc}
*/
@Override
public void setAsText(String text) {
if (StringUtils.isNotEmpty(text)) {
String[] materialTypes = TokenizerUtil.split(text);
Set<MaterialType> result = new HashSet<MaterialType>();
for (String matType : materialTypes) {
MaterialType materialType = MaterialType.valueOf(matType);
if (materialType == null) {
throw new IllegalArgumentException("Material type ["
+ materialType + "] not found");
}
result.add(materialType);
}
setValue(result);
} else {
setValue(null);
}
}
}
Yes, we think about cloning the original entity before applying the changes, but we hoped that there might be another/a better solution to this problem.