Fixed with a custom resolver:
faces-config.xml:
<application>
<el-resolver>my.package.EmptyNullStringResolver</el-resolver>
</application>
EmptyNullStringResolver.java:
/**
* @author pg
*/
public class EmptyNullStringResolver extends ELResolver {
@Override
public Class<?> getCommonPropertyType(ELContext context, Object base) {
return String.class;
}
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
return null;
}
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
return null;
}
@Override
public Object getValue(ELContext context, Object base, Object property) {
return null;
}
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
return true;
}
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
}
@Override
public Object convertToType(ELContext context, Object obj, Class<?> targetType) {
if (String.class.equals(targetType) && obj instanceof String && ((String) obj).trim().isEmpty()) {
context.setPropertyResolved(true);
}
return null;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…