IN PROGRESS - issue SWF-720: Multiple checkboxes to Collection mapping

http://jira.springframework.org/browse/SWF-720
This commit is contained in:
Keith Donald
2008-07-05 22:08:30 +00:00
parent e2b6d51cbd
commit b0ec648fc6
5 changed files with 23 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package org.springframework.faces.config;
import junit.framework.TestCase;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
@@ -71,6 +72,10 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
public static class TestConversionService implements ConversionService {
public Object executeConversion(Object source, Class targetClass) throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.webflow.engine.builder.support;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
@@ -119,6 +120,10 @@ public class FlowBuilderContextImpl implements FlowBuilderContext {
* A little proxy that refreshes the externally configured conversion service reference on each invocation.
*/
private class ParentConversionServiceProxy implements ConversionService {
public Object executeConversion(Object source, Class targetClass) throws ConversionException {
return getFlowBuilderServices().getConversionService().executeConversion(source, targetClass);
}
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionExecutionException {
return getFlowBuilderServices().getConversionService().getConversionExecutor(sourceClass, targetClass);

View File

@@ -274,7 +274,6 @@ public abstract class AbstractMvcView implements View {
logger.debug("Setting up view->model mappings");
}
DefaultMapper mapper = new DefaultMapper();
mapper.setConversionService(conversionService);
ParameterMap requestParameters = requestContext.getRequestParameters();
addDefaultMappings(mapper, requestParameters.asMap().keySet(), model);
return mapper.map(requestParameters, model);

View File

@@ -16,8 +16,10 @@
package org.springframework.webflow.mvc.view;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
@@ -142,6 +144,12 @@ public class BindingModel extends AbstractErrors {
private ConversionExecutor getConverter(Expression fieldExpression) {
if (conversionService != null) {
Class valueType = fieldExpression.getValueType(boundObject);
// TODO -- this really is not accurate for Collection or Array or Map types
// This needs to be cleaned up
if (valueType.isArray() || Collection.class.isAssignableFrom(valueType)
|| Map.class.isAssignableFrom(valueType)) {
return null;
}
return conversionService.getConversionExecutor(valueType, String.class);
} else {
return null;

View File

@@ -2,6 +2,7 @@ package org.springframework.webflow.config;
import junit.framework.TestCase;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
@@ -54,6 +55,10 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
public static class TestConversionService implements ConversionService {
public Object executeConversion(Object source, Class targetClass) throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");