IN PROGRESS - issue SWF-720: Multiple checkboxes to Collection mapping
http://jira.springframework.org/browse/SWF-720
This commit is contained in:
@@ -24,12 +24,15 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class StringToClass extends StringToObject {
|
||||
|
||||
public StringToClass() {
|
||||
private ClassLoader classLoader;
|
||||
|
||||
public StringToClass(ClassLoader classLoader) {
|
||||
super(Class.class);
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class objectClass) throws Exception {
|
||||
return ClassUtils.forName(string);
|
||||
return ClassUtils.forName(string, classLoader);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.binding.convert.ConversionService;
|
||||
import org.springframework.binding.convert.converters.StringToBigDecimal;
|
||||
import org.springframework.binding.convert.converters.StringToBigInteger;
|
||||
@@ -36,6 +37,7 @@ import org.springframework.binding.convert.converters.StringToLocale;
|
||||
import org.springframework.binding.convert.converters.StringToLong;
|
||||
import org.springframework.binding.convert.converters.StringToShort;
|
||||
import org.springframework.core.enums.LabeledEnum;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Default, local implementation of a conversion service. Will automatically register <i>from string</i> converters for
|
||||
@@ -43,13 +45,15 @@ import org.springframework.core.enums.LabeledEnum;
|
||||
*
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public class DefaultConversionService extends GenericConversionService {
|
||||
public class DefaultConversionService extends GenericConversionService implements BeanClassLoaderAware {
|
||||
|
||||
/**
|
||||
* A singleton shared instance. Should never be modified.
|
||||
*/
|
||||
private static DefaultConversionService SHARED_INSTANCE;
|
||||
|
||||
private ClassLoader classLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
/**
|
||||
* Creates a new default conversion service, installing the default converters.
|
||||
*/
|
||||
@@ -72,7 +76,7 @@ public class DefaultConversionService extends GenericConversionService {
|
||||
addConverter(new StringToDouble());
|
||||
addConverter(new StringToBigInteger());
|
||||
addConverter(new StringToBigDecimal());
|
||||
addConverter(new StringToClass());
|
||||
addConverter(new StringToClass(classLoader));
|
||||
addConverter(new StringToLocale());
|
||||
addConverter(new StringToDate());
|
||||
addConverter(new StringToLabeledEnum());
|
||||
@@ -96,6 +100,10 @@ public class DefaultConversionService extends GenericConversionService {
|
||||
addAlias("labeledEnum", LabeledEnum.class);
|
||||
}
|
||||
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared {@link DefaultConversionService} instance.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user