blank == null
This commit is contained in:
parent
f4a01884bd
commit
d94eca4ee7
4 changed files with 6 additions and 66 deletions
|
@ -9,17 +9,6 @@ import stirling.software.SPDF.model.ApplicationProperties;
|
|||
@Configuration
|
||||
public class AppConfig {
|
||||
|
||||
@Bean
|
||||
public CustomEditorConfigurer customEditorConfigurer() {
|
||||
return new CustomEditorConfigurer();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PropertyEditorRegistrar propertyEditorRegistrar() {
|
||||
return registry -> {
|
||||
registry.registerCustomEditor(String.class, new EmptyStringAsNullEditor());
|
||||
};
|
||||
}
|
||||
|
||||
@Autowired
|
||||
ApplicationProperties applicationProperties;
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
package stirling.software.SPDF.config;
|
||||
import java.beans.PropertyEditor;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyEditorRegistrar;
|
||||
import org.springframework.beans.PropertyEditorRegistry;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.validation.DataBinder;
|
||||
|
||||
public class CustomEditorConfigurer implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof PropertyEditorRegistrar) {
|
||||
((PropertyEditorRegistrar) bean).registerCustomEditors(new PropertyEditorRegistry() {
|
||||
@Override
|
||||
public void registerCustomEditor(Class<?> requiredType, String propertyPath, java.beans.PropertyEditor propertyEditor) {
|
||||
DataBinder dataBinder = new DataBinder(bean);
|
||||
dataBinder.registerCustomEditor(requiredType, propertyPath, propertyEditor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomEditor(Class<?> requiredType, java.beans.PropertyEditor propertyEditor) {
|
||||
DataBinder dataBinder = new DataBinder(bean);
|
||||
dataBinder.registerCustomEditor(requiredType, propertyEditor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package stirling.software.SPDF.config;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
public class EmptyStringAsNullEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
if (text != null && text.trim().isEmpty()) {
|
||||
setValue(null);
|
||||
} else {
|
||||
setValue(text);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -232,6 +232,8 @@ public class ApplicationProperties {
|
|||
private String appNameNavbar;
|
||||
|
||||
public String getAppName() {
|
||||
if(appName != null && appName.trim().length() == 0)
|
||||
return null;
|
||||
return appName;
|
||||
}
|
||||
|
||||
|
@ -240,6 +242,8 @@ public class ApplicationProperties {
|
|||
}
|
||||
|
||||
public String getHomeDescription() {
|
||||
if(homeDescription != null && homeDescription.trim().length() == 0)
|
||||
return null;
|
||||
return homeDescription;
|
||||
}
|
||||
|
||||
|
@ -248,6 +252,8 @@ public class ApplicationProperties {
|
|||
}
|
||||
|
||||
public String getAppNameNavbar() {
|
||||
if(appNameNavbar != null && appNameNavbar.trim().length() == 0)
|
||||
return null;
|
||||
return appNameNavbar;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue