From 34907cd5245a0d993b68a8073f70339d6af34a76 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Thu, 20 Mar 2008 23:35:39 +0000 Subject: [PATCH] formatter registry service integration --- ...owBuilderServicesBeanDefinitionParser.java | 30 ++++++++++++++-- .../faces/webflow/JsfViewFactoryCreator.java | 5 ++- .../EnableFlowScopesBeanDefinitionParser.java | 35 ------------------- ...owBuilderServicesBeanDefinitionParser.java | 27 ++++++++++++++ .../config/WebFlowConfigNamespaceHandler.java | 1 - .../config/spring-webflow-config-2.0.xsd | 11 ------ .../engine/builder/FlowBuilderContext.java | 17 ++++----- .../engine/builder/ViewFactoryCreator.java | 8 +++-- .../support/FlowBuilderContextImpl.java | 14 ++++---- .../builder/support/FlowBuilderServices.java | 31 ++++++++-------- .../builder/xml/LocalFlowBuilderContext.java | 19 +++++----- .../engine/builder/xml/XmlFlowBuilder.java | 13 ++++--- .../webflow/mvc/view/BindingModel.java | 18 +++++++--- .../InternalFlowResourceMvcViewFactory.java | 24 ++++++++++--- .../webflow/mvc/view/MvcView.java | 21 +++++------ .../mvc/view/MvcViewFactoryCreator.java | 12 +++---- .../mvc/view/ViewResolvingMvcViewFactory.java | 22 +++++++++--- .../webflow/test/MockViewFactoryCreator.java | 12 +++---- ...EnableScopesBeanDefinitionParserTests.java | 34 ------------------ ...lderServicesBeanDefinitionParserTests.java | 10 +++--- .../webflow/mvc/view/MvcViewFactoryTests.java | 9 +++-- .../webflow/mvc/view/MvcViewTests.java | 14 ++++++++ 22 files changed, 204 insertions(+), 183 deletions(-) delete mode 100644 spring-webflow/src/main/java/org/springframework/webflow/config/EnableFlowScopesBeanDefinitionParser.java delete mode 100644 spring-webflow/src/test/java/org/springframework/webflow/config/EnableScopesBeanDefinitionParserTests.java diff --git a/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java b/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java index 703f920a..192146e4 100644 --- a/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java +++ b/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java @@ -19,9 +19,13 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.binding.expression.el.DefaultExpressionFactoryUtils; +import org.springframework.binding.format.FormatterRegistry; +import org.springframework.binding.format.factories.DateFormatterFactory; +import org.springframework.binding.format.factories.NumberFormatterFactory; +import org.springframework.binding.format.impl.FormatterRegistryImpl; import org.springframework.faces.model.converter.FacesConversionService; -import org.springframework.faces.webflow.JsfViewFactoryCreator; import org.springframework.faces.webflow.JsfManagedBeanAwareELExpressionParser; +import org.springframework.faces.webflow.JsfViewFactoryCreator; import org.springframework.util.StringUtils; import org.springframework.webflow.engine.builder.support.FlowBuilderServices; import org.springframework.webflow.expression.el.WebFlowELExpressionParser; @@ -47,6 +51,10 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle private static final String CONVERSION_SERVICE_PROPERTY = "conversionService"; + private static final String FORMATTER_REGISTRY_ATTRIBUTE = "formatter-registry"; + + private static final String FORMATTER_REGISTRY_PROPERTY = "formatterRegistry"; + protected Class getBeanClass(Element element) { return FlowBuilderServices.class; } @@ -59,8 +67,9 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle } else { parseExpressionParser(element, definitionBuilder); } - parseViewFactoryCreator(element, definitionBuilder); + parseFormatterRegistry(element, definitionBuilder); parseConversionService(element, definitionBuilder); + parseViewFactoryCreator(element, definitionBuilder); } private boolean parseEnableManagedBeans(Element element, BeanDefinitionBuilder definitionBuilder) { @@ -72,6 +81,15 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle } } + private void parseFormatterRegistry(Element element, BeanDefinitionBuilder definitionBuilder) { + String formatterRegistry = element.getAttribute(FORMATTER_REGISTRY_ATTRIBUTE); + if (StringUtils.hasText(formatterRegistry)) { + definitionBuilder.addPropertyReference(FORMATTER_REGISTRY_PROPERTY, formatterRegistry); + } else { + definitionBuilder.addPropertyValue(FORMATTER_REGISTRY_PROPERTY, createDefaultFormatterRegistry()); + } + } + private void parseConversionService(Element element, BeanDefinitionBuilder definitionBuilder) { String conversionService = element.getAttribute(CONVERSION_SERVICE_ATTRIBUTE); if (StringUtils.hasText(conversionService)) { @@ -99,4 +117,12 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle DefaultExpressionFactoryUtils.createExpressionFactory())); } } + + private static FormatterRegistry createDefaultFormatterRegistry() { + FormatterRegistryImpl registry = new FormatterRegistryImpl(); + registry.registerFormatter(new NumberFormatterFactory()); + registry.registerFormatter(new DateFormatterFactory()); + return registry; + } + } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java index 9175ca55..56725ffc 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java @@ -18,6 +18,8 @@ package org.springframework.faces.webflow; import javax.faces.lifecycle.Lifecycle; import org.springframework.binding.expression.Expression; +import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.core.io.ResourceLoader; import org.springframework.webflow.engine.builder.ViewFactoryCreator; import org.springframework.webflow.execution.ViewFactory; @@ -33,7 +35,8 @@ public class JsfViewFactoryCreator implements ViewFactoryCreator { private Lifecycle lifecycle; - public ViewFactory createViewFactory(Expression viewIdExpression, ResourceLoader resourceLoader) { + public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, ResourceLoader resourceLoader) { return new JsfViewFactory(viewIdExpression, resourceLoader, getLifecycle()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/EnableFlowScopesBeanDefinitionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/config/EnableFlowScopesBeanDefinitionParser.java deleted file mode 100644 index ec70fb4b..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/EnableFlowScopesBeanDefinitionParser.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2004-2008 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.webflow.config; - -import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; -import org.springframework.beans.factory.xml.BeanDefinitionParser; -import org.springframework.webflow.config.scope.ScopeRegistrar; -import org.w3c.dom.Element; - -/** - * {@link BeanDefinitionParser} for the <enable-flow-scopes> tag. - * @author Ben Hale - */ -class EnableFlowScopesBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { - protected Class getBeanClass(Element element) { - return ScopeRegistrar.class; - } - - protected boolean shouldGenerateId() { - return true; - } -} diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParser.java index 6e5012b4..5e56928f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParser.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParser.java @@ -7,6 +7,10 @@ import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.binding.convert.support.DefaultConversionService; +import org.springframework.binding.format.FormatterRegistry; +import org.springframework.binding.format.factories.DateFormatterFactory; +import org.springframework.binding.format.factories.NumberFormatterFactory; +import org.springframework.binding.format.impl.FormatterRegistryImpl; import org.springframework.util.StringUtils; import org.springframework.webflow.engine.builder.support.FlowBuilderServices; import org.springframework.webflow.expression.DefaultExpressionParserFactory; @@ -20,12 +24,16 @@ import org.w3c.dom.Element; */ class FlowBuilderServicesBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { + private static final String FORMATTER_REGISTRY_ATTRIBUTE = "formatter-registry"; + private static final String CONVERSION_SERVICE_ATTRIBUTE = "conversion-service"; private static final String EXPRESSION_PARSER_ATTRIBUTE = "expression-parser"; private static final String VIEW_FACTORY_CREATOR_ATTRIBUTE = "view-factory-creator"; + private static final String FORMATTER_REGISTRY_PROPERTY = "formatterRegistry"; + private static final String CONVERSION_SERVICE_PROPERTY = "conversionService"; private static final String EXPRESSION_PARSER_PROPERTY = "expressionParser"; @@ -37,11 +45,21 @@ class FlowBuilderServicesBeanDefinitionParser extends AbstractSingleBeanDefiniti } protected void doParse(Element element, ParserContext context, BeanDefinitionBuilder builder) { + parseFormatterRegistry(element, builder, context); parseConversionService(element, builder, context); parseExpressionParser(element, builder, context); parseViewFactoryCreator(element, builder, context); } + private void parseFormatterRegistry(Element element, BeanDefinitionBuilder definitionBuilder, ParserContext context) { + String formatterRegistry = element.getAttribute(FORMATTER_REGISTRY_ATTRIBUTE); + if (StringUtils.hasText(formatterRegistry)) { + definitionBuilder.addPropertyReference(FORMATTER_REGISTRY_PROPERTY, formatterRegistry); + } else { + definitionBuilder.addPropertyValue(FORMATTER_REGISTRY_PROPERTY, createDefaultFormatterRegistry()); + } + } + private void parseConversionService(Element element, BeanDefinitionBuilder definitionBuilder, ParserContext context) { String conversionService = element.getAttribute(CONVERSION_SERVICE_ATTRIBUTE); if (StringUtils.hasText(conversionService)) { @@ -82,6 +100,7 @@ class FlowBuilderServicesBeanDefinitionParser extends AbstractSingleBeanDefiniti public static BeanDefinitionHolder registerDefaultFlowBuilderServicesBeanDefinition(ParserContext context) { FlowBuilderServicesBeanDefinitionParser parser = new FlowBuilderServicesBeanDefinitionParser(); BeanDefinitionBuilder defaultBuilder = BeanDefinitionBuilder.genericBeanDefinition(FlowBuilderServices.class); + defaultBuilder.addPropertyValue(FORMATTER_REGISTRY_PROPERTY, createDefaultFormatterRegistry()); defaultBuilder.addPropertyValue(CONVERSION_SERVICE_PROPERTY, new DefaultConversionService()); defaultBuilder.addPropertyValue(EXPRESSION_PARSER_PROPERTY, DefaultExpressionParserFactory .getExpressionParser()); @@ -92,4 +111,12 @@ class FlowBuilderServicesBeanDefinitionParser extends AbstractSingleBeanDefiniti parser.registerBeanDefinition(holder, context.getRegistry()); return holder; } + + private static FormatterRegistry createDefaultFormatterRegistry() { + FormatterRegistryImpl registry = new FormatterRegistryImpl(); + registry.registerFormatter(new NumberFormatterFactory()); + registry.registerFormatter(new DateFormatterFactory()); + return registry; + } + } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/WebFlowConfigNamespaceHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/config/WebFlowConfigNamespaceHandler.java index 612d1039..3ca473d6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/WebFlowConfigNamespaceHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/WebFlowConfigNamespaceHandler.java @@ -30,6 +30,5 @@ public class WebFlowConfigNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionParser("flow-execution-listeners", new FlowExecutionListenerLoaderBeanDefinitionParser()); registerBeanDefinitionParser("flow-registry", new FlowRegistryBeanDefinitionParser()); registerBeanDefinitionParser("flow-builder-services", new FlowBuilderServicesBeanDefinitionParser()); - registerBeanDefinitionParser("enable-flow-scopes", new EnableFlowScopesBeanDefinitionParser()); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/spring-webflow-config-2.0.xsd b/spring-webflow/src/main/java/org/springframework/webflow/config/spring-webflow-config-2.0.xsd index 576cf2d8..6661f713 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/spring-webflow-config-2.0.xsd +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/spring-webflow-config-2.0.xsd @@ -208,17 +208,6 @@ The default value 'flowRegistry'. - - - - - - - - diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java index b16a4e52..d8f4039a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java @@ -18,8 +18,8 @@ package org.springframework.webflow.engine.builder; import org.springframework.beans.factory.BeanFactory; import org.springframework.binding.convert.ConversionService; import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.core.io.ResourceLoader; -import org.springframework.webflow.action.BeanInvokingActionFactory; import org.springframework.webflow.core.collection.AttributeMap; import org.springframework.webflow.definition.registry.FlowDefinitionLocator; @@ -54,10 +54,11 @@ public interface FlowBuilderContext { public FlowArtifactFactory getFlowArtifactFactory(); /** - * Returns the factory for bean invoking actions. - * @return the bean invoking action factory + * Returns a generic type conversion service for converting between types, typically from string to a rich value + * object. + * @return the generic conversion service */ - public BeanInvokingActionFactory getBeanInvokingActionFactory(); + public ConversionService getConversionService(); /** * Returns the view factory creator for configuring a ViewFactory per view state @@ -72,11 +73,10 @@ public interface FlowBuilderContext { public ExpressionParser getExpressionParser(); /** - * Returns a generic type conversion service for converting between types, typically from string to a rich value - * object. - * @return the generic conversion service + * Returns an application-wide registry of formatters for formatting view values. + * @return the formatter registry */ - public ConversionService getConversionService(); + public FormatterRegistry getFormatterRegistry(); /** * Returns a generic resource loader for accessing file-based resources. @@ -89,4 +89,5 @@ public interface FlowBuilderContext { * @return the bean factory */ public BeanFactory getBeanFactory(); + } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java index 62815c73..6165de5f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java @@ -16,6 +16,8 @@ package org.springframework.webflow.engine.builder; import org.springframework.binding.expression.Expression; +import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.core.io.ResourceLoader; import org.springframework.webflow.execution.View; import org.springframework.webflow.execution.ViewFactory; @@ -30,10 +32,12 @@ public interface ViewFactoryCreator { * Create a view factory capable of creating {@link View} objects that can render the view template with the * provided identifier. * @param viewIdExpression an expression that resolves the id of the view template - * @param viewResourceLoader an optional resource loader to use to load the view template from an input stream + * @param expressionParser an optional expression parser to use to resolve view expressions + * @param formatterRegistry an optional formatter registry to use to format text values * @return the view factory */ - public ViewFactory createViewFactory(Expression viewIdExpression, ResourceLoader viewResourceLoader); + public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, ResourceLoader resourceLoader); /** * Get the default id of the view to render in the provided view state by convention. diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java index 471994fb..209e9ed6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java @@ -4,9 +4,9 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.binding.convert.ConversionService; import org.springframework.binding.convert.support.GenericConversionService; import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.core.io.ResourceLoader; import org.springframework.util.Assert; -import org.springframework.webflow.action.BeanInvokingActionFactory; import org.springframework.webflow.core.collection.AttributeMap; import org.springframework.webflow.definition.registry.FlowDefinitionLocator; import org.springframework.webflow.engine.builder.FlowArtifactFactory; @@ -66,20 +66,20 @@ public class FlowBuilderContextImpl implements FlowBuilderContext { return flowBuilderServices.getFlowArtifactFactory(); } - public BeanInvokingActionFactory getBeanInvokingActionFactory() { - return flowBuilderServices.getBeanInvokingActionFactory(); + public ConversionService getConversionService() { + return conversionService; } public ViewFactoryCreator getViewFactoryCreator() { return flowBuilderServices.getViewFactoryCreator(); } - public ExpressionParser getExpressionParser() { - return flowBuilderServices.getExpressionParser(); + public FormatterRegistry getFormatterRegistry() { + return flowBuilderServices.getFormatterRegistry(); } - public ConversionService getConversionService() { - return conversionService; + public ExpressionParser getExpressionParser() { + return flowBuilderServices.getExpressionParser(); } public ResourceLoader getResourceLoader() { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderServices.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderServices.java index c5c23faa..0437f668 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderServices.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderServices.java @@ -6,6 +6,7 @@ import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.binding.convert.ConversionService; import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.ResourceLoader; import org.springframework.util.Assert; @@ -15,7 +16,6 @@ import org.springframework.webflow.engine.State; import org.springframework.webflow.engine.builder.FlowArtifactFactory; import org.springframework.webflow.engine.builder.FlowBuilderContext; import org.springframework.webflow.engine.builder.ViewFactoryCreator; -import org.springframework.webflow.execution.Action; /** * A simple holder for configuring the services used by flow builders. These services are exposed to a builder in a @@ -37,12 +37,6 @@ public class FlowBuilderServices implements ResourceLoaderAware, BeanFactoryAwar */ private FlowArtifactFactory flowArtifactFactory = new FlowArtifactFactory(); - /** - * The factory encapsulating the creation of bean invoking actions, actions that adapt methods on objects to the - * {@link Action} interface. - */ - private BeanInvokingActionFactory beanInvokingActionFactory = new BeanInvokingActionFactory(); - /** * The view factory creator for creating views to render during flow execution. The default is null * and this service must be configured externally. @@ -54,6 +48,11 @@ public class FlowBuilderServices implements ResourceLoaderAware, BeanFactoryAwar */ private ConversionService conversionService; + /** + * The service for formatting string values for display in a UI. + */ + private FormatterRegistry formatterRegistry; + /** * The parser for parsing expression strings into expression objects. The default is Web Flow's default expression * parser implementation. @@ -78,14 +77,6 @@ public class FlowBuilderServices implements ResourceLoaderAware, BeanFactoryAwar this.flowArtifactFactory = flowArtifactFactory; } - public BeanInvokingActionFactory getBeanInvokingActionFactory() { - return beanInvokingActionFactory; - } - - public void setBeanInvokingActionFactory(BeanInvokingActionFactory beanInvokingActionFactory) { - this.beanInvokingActionFactory = beanInvokingActionFactory; - } - public ViewFactoryCreator getViewFactoryCreator() { return viewFactoryCreator; } @@ -102,6 +93,14 @@ public class FlowBuilderServices implements ResourceLoaderAware, BeanFactoryAwar this.conversionService = conversionService; } + public FormatterRegistry getFormatterRegistry() { + return formatterRegistry; + } + + public void setFormatterRegistry(FormatterRegistry formatterRegistry) { + this.formatterRegistry = formatterRegistry; + } + public ExpressionParser getExpressionParser() { return expressionParser; } @@ -130,9 +129,9 @@ public class FlowBuilderServices implements ResourceLoaderAware, BeanFactoryAwar public void afterPropertiesSet() throws Exception { Assert.notNull(flowArtifactFactory, "The flow artifact factory is required"); - Assert.notNull(beanInvokingActionFactory, "The bean invoking action factory is required"); Assert.notNull(viewFactoryCreator, "The view factory creator is required"); Assert.notNull(conversionService, "The type conversion service is required"); + Assert.notNull(formatterRegistry, "The formatter registry is required"); Assert.notNull(expressionParser, "The expression parser is required"); Assert.notNull(resourceLoader, "The resource loader is required"); Assert.notNull(beanFactory, "The bean factory is required"); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/LocalFlowBuilderContext.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/LocalFlowBuilderContext.java index 527b41ba..43f7ce7b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/LocalFlowBuilderContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/LocalFlowBuilderContext.java @@ -18,9 +18,9 @@ package org.springframework.webflow.engine.builder.xml; import org.springframework.beans.factory.BeanFactory; import org.springframework.binding.convert.ConversionService; import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ResourceLoader; -import org.springframework.webflow.action.BeanInvokingActionFactory; import org.springframework.webflow.core.collection.AttributeMap; import org.springframework.webflow.definition.registry.FlowDefinitionLocator; import org.springframework.webflow.engine.builder.FlowArtifactFactory; @@ -67,12 +67,11 @@ class LocalFlowBuilderContext implements FlowBuilderContext { } } - public BeanInvokingActionFactory getBeanInvokingActionFactory() { - if (localFlowContext.containsLocalBean("beanInvokingActionFactory")) { - return (BeanInvokingActionFactory) localFlowContext.getBean("beanInvokingActionFactory", - BeanInvokingActionFactory.class); + public ConversionService getConversionService() { + if (localFlowContext.containsLocalBean("conversionService")) { + return (ConversionService) localFlowContext.getBean("conversionService", ConversionService.class); } else { - return parent.getBeanInvokingActionFactory(); + return parent.getConversionService(); } } @@ -84,11 +83,11 @@ class LocalFlowBuilderContext implements FlowBuilderContext { } } - public ConversionService getConversionService() { - if (localFlowContext.containsLocalBean("conversionService")) { - return (ConversionService) localFlowContext.getBean("conversionService", ConversionService.class); + public FormatterRegistry getFormatterRegistry() { + if (localFlowContext.containsLocalBean("formatterRegistry")) { + return (FormatterRegistry) localFlowContext.getBean("formatterRegistry", FormatterRegistry.class); } else { - return parent.getConversionService(); + return parent.getFormatterRegistry(); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/XmlFlowBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/XmlFlowBuilder.java index 12747f0b..628ba7dc 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/XmlFlowBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/xml/XmlFlowBuilder.java @@ -602,10 +602,9 @@ public class XmlFlowBuilder extends AbstractFlowBuilder implements ResourceHolde return null; } else { encodedView = getLocalContext().getViewFactoryCreator().getViewIdByConvention(parseId(element)); - Expression viewName = getExpressionParser().parseExpression(encodedView, + Expression viewId = getExpressionParser().parseExpression(encodedView, new ParserContextImpl().template().eval(RequestContext.class).expect(String.class)); - return getLocalContext().getViewFactoryCreator().createViewFactory(viewName, - getLocalContext().getResourceLoader()); + return createViewFactory(element, viewId); } } else if (encodedView.startsWith("externalRedirect:")) { String encodedUrl = encodedView.substring("externalRedirect:".length()); @@ -620,11 +619,15 @@ public class XmlFlowBuilder extends AbstractFlowBuilder implements ResourceHolde } else { Expression viewId = getExpressionParser().parseExpression(encodedView, new ParserContextImpl().template().eval(RequestContext.class).expect(String.class)); - return getLocalContext().getViewFactoryCreator().createViewFactory(viewId, - getLocalContext().getResourceLoader()); + return createViewFactory(element, viewId); } } + private ViewFactory createViewFactory(Element element, Expression viewId) { + return getLocalContext().getViewFactoryCreator().createViewFactory(viewId, getExpressionParser(), + getLocalContext().getFormatterRegistry(), getLocalContext().getResourceLoader()); + } + private Action[] parseRenderActions(Element element) { Element renderActionsElement = DomUtils.getChildElementByTagName(element, "on-render"); if (renderActionsElement != null) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java index 47728c87..5044d806 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java @@ -69,13 +69,21 @@ public class BindingModel extends ViewRenderingErrors { } private Object getFormattedValue(String field) { - Expression exp = parseFieldExpression(field); - Class valueType = exp.getValueType(boundObject); - Formatter formatter = formatterRegistry.getFormatter(valueType); + Expression fieldExpression = parseFieldExpression(field); + Formatter formatter = getFormatter(fieldExpression); if (formatter != null) { - return formatter.formatValue(exp.getValue(boundObject)); + return formatter.formatValue(fieldExpression.getValue(boundObject)); } else { - return exp.getValue(boundObject); + return fieldExpression.getValue(boundObject); + } + } + + private Formatter getFormatter(Expression fieldExpression) { + if (formatterRegistry != null) { + Class valueType = fieldExpression.getValueType(boundObject); + return formatterRegistry.getFormatter(valueType); + } else { + return null; } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/InternalFlowResourceMvcViewFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/InternalFlowResourceMvcViewFactory.java index 12209d15..6236f26e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/InternalFlowResourceMvcViewFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/InternalFlowResourceMvcViewFactory.java @@ -1,6 +1,8 @@ package org.springframework.webflow.mvc.view; import org.springframework.binding.expression.Expression; +import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.context.ApplicationContext; import org.springframework.core.io.ContextResource; import org.springframework.core.io.ResourceLoader; @@ -25,9 +27,15 @@ class InternalFlowResourceMvcViewFactory implements ViewFactory { private ResourceLoader resourceLoader; - public InternalFlowResourceMvcViewFactory(Expression viewIdExpression, ApplicationContext context, - ResourceLoader resourceLoader) { + private ExpressionParser expressionParser; + + private FormatterRegistry formatterRegistry; + + public InternalFlowResourceMvcViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, ApplicationContext context, ResourceLoader resourceLoader) { this.viewIdExpression = viewIdExpression; + this.expressionParser = expressionParser; + this.formatterRegistry = formatterRegistry; this.applicationContext = context; this.resourceLoader = resourceLoader; } @@ -47,14 +55,22 @@ class InternalFlowResourceMvcViewFactory implements ViewFactory { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(applicationContext); - return new MvcView(view, context); + return createMvcView(view, context); } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(applicationContext); - return new MvcView(view, context); + return createMvcView(view, context); } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported are [.jsp]"); } } + + private MvcView createMvcView(org.springframework.web.servlet.View view, RequestContext context) { + MvcView mvcView = new MvcView(view, context); + mvcView.setExpressionParser(expressionParser); + mvcView.setFormatterRegistry(formatterRegistry); + return mvcView; + } + } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java index dbdedbf8..31c5a4f7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java @@ -32,9 +32,6 @@ import org.springframework.binding.expression.ExpressionParser; import org.springframework.binding.expression.support.ParserContextImpl; import org.springframework.binding.format.Formatter; import org.springframework.binding.format.FormatterRegistry; -import org.springframework.binding.format.factories.DateFormatterFactory; -import org.springframework.binding.format.factories.NumberFormatterFactory; -import org.springframework.binding.format.impl.FormatterRegistryImpl; import org.springframework.binding.mapping.MappingResult; import org.springframework.binding.mapping.MappingResults; import org.springframework.binding.mapping.MappingResultsCriteria; @@ -72,7 +69,6 @@ class MvcView implements View { public MvcView(org.springframework.web.servlet.View view, RequestContext context) { this.view = view; this.context = context; - this.formatterRegistry = createDefaultFormatterRegistry(); } public void setExpressionParser(ExpressionParser expressionParser) { @@ -130,13 +126,6 @@ class MvcView implements View { return new Event(this, eventId, context.getRequestParameters().asAttributeMap()); } - protected FormatterRegistry createDefaultFormatterRegistry() { - FormatterRegistryImpl registry = new FormatterRegistryImpl(); - registry.registerFormatter(new NumberFormatterFactory()); - registry.registerFormatter(new DateFormatterFactory()); - return registry; - } - private Map flowScopes() { return context.getConversationScope().union(context.getFlowScope()).union(context.getFlashScope()).union( context.getRequestScope()).asMap(); @@ -279,7 +268,7 @@ class MvcView implements View { if (targetClass == null) { return formattedValue; } - Formatter formatter = formatterRegistry.getFormatter(target.getExpressionString(), targetClass); + Formatter formatter = getFormatter(target, targetClass); if (formatter != null) { return formatter.parseValue(formattedValue); } else { @@ -287,6 +276,14 @@ class MvcView implements View { } } + private Formatter getFormatter(Expression target, Class targetClass) { + if (formatterRegistry != null) { + return formatterRegistry.getFormatter(target.getExpressionString(), targetClass); + } else { + return null; + } + } + public Class getSourceClass() { return String.class; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcViewFactoryCreator.java index b174395d..dafa2887 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcViewFactoryCreator.java @@ -40,10 +40,6 @@ import org.springframework.webflow.execution.ViewFactory; */ public class MvcViewFactoryCreator implements ViewFactoryCreator, ApplicationContextAware { - private ExpressionParser expressionParser; - - private FormatterRegistry formatterRegistry; - private List viewResolvers; private ApplicationContext applicationContext; @@ -61,11 +57,13 @@ public class MvcViewFactoryCreator implements ViewFactoryCreator, ApplicationCon this.applicationContext = context; } - public ViewFactory createViewFactory(Expression viewIdExpression, ResourceLoader viewResourceLoader) { + public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, ResourceLoader resourceLoader) { if (viewResolvers != null) { - return new ViewResolvingMvcViewFactory(viewIdExpression, viewResolvers); + return new ViewResolvingMvcViewFactory(viewIdExpression, expressionParser, formatterRegistry, viewResolvers); } else { - return new InternalFlowResourceMvcViewFactory(viewIdExpression, applicationContext, viewResourceLoader); + return new InternalFlowResourceMvcViewFactory(viewIdExpression, expressionParser, formatterRegistry, + applicationContext, resourceLoader); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/ViewResolvingMvcViewFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/ViewResolvingMvcViewFactory.java index 893d23de..99c98eaa 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/ViewResolvingMvcViewFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/ViewResolvingMvcViewFactory.java @@ -2,8 +2,11 @@ package org.springframework.webflow.mvc.view; import java.util.Iterator; import java.util.List; +import java.util.Locale; import org.springframework.binding.expression.Expression; +import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.web.servlet.ViewResolver; import org.springframework.webflow.execution.RequestContext; @@ -16,26 +19,35 @@ import org.springframework.webflow.execution.ViewFactory; * @author Keith Donald */ class ViewResolvingMvcViewFactory implements ViewFactory { + private Expression viewIdExpression; + private ExpressionParser expressionParser; + + private FormatterRegistry formatterRegistry; + private List viewResolvers; - public ViewResolvingMvcViewFactory(Expression viewIdExpression, List viewResolvers) { + public ViewResolvingMvcViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, List viewResolvers) { this.viewIdExpression = viewIdExpression; this.viewResolvers = viewResolvers; } public View getView(RequestContext context) { - String view = (String) viewIdExpression.getValue(context); - return new MvcView(resolveView(view), context); + String viewName = (String) viewIdExpression.getValue(context); + MvcView view = new MvcView(resolveView(viewName), context); + view.setExpressionParser(expressionParser); + view.setFormatterRegistry(formatterRegistry); + return view; } protected org.springframework.web.servlet.View resolveView(String viewName) { for (Iterator it = viewResolvers.iterator(); it.hasNext();) { ViewResolver viewResolver = (ViewResolver) it.next(); try { - org.springframework.web.servlet.View view = viewResolver.resolveViewName(viewName, - LocaleContextHolder.getLocale()); + Locale locale = LocaleContextHolder.getLocale(); + org.springframework.web.servlet.View view = viewResolver.resolveViewName(viewName, locale); if (view != null) { return view; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java index 85c1c98e..4c88389f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java @@ -18,10 +18,10 @@ package org.springframework.webflow.test; import java.io.IOException; import org.springframework.binding.expression.Expression; +import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.core.io.ResourceLoader; -import org.springframework.webflow.action.ViewFactoryActionAdapter; import org.springframework.webflow.engine.builder.ViewFactoryCreator; -import org.springframework.webflow.execution.Action; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; import org.springframework.webflow.execution.View; @@ -34,12 +34,10 @@ import org.springframework.webflow.execution.ViewFactory; * @author Keith Donald */ class MockViewFactoryCreator implements ViewFactoryCreator { - public Action createRenderViewAction(Expression viewId, ResourceLoader viewResourceLoader) { - return new ViewFactoryActionAdapter(createViewFactory(viewId, viewResourceLoader)); - } - public ViewFactory createViewFactory(Expression viewId, ResourceLoader viewResourceLoader) { - return new MockViewFactory(viewId); + public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, ResourceLoader resourceLoader) { + return new MockViewFactory(viewIdExpression); } public String getViewIdByConvention(String viewStateId) { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/EnableScopesBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/EnableScopesBeanDefinitionParserTests.java deleted file mode 100644 index d54a6555..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/EnableScopesBeanDefinitionParserTests.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.springframework.webflow.config; - -import junit.framework.TestCase; - -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.webflow.core.collection.AttributeMap; -import org.springframework.webflow.execution.FlowExecutionListenerAdapter; -import org.springframework.webflow.execution.FlowSession; -import org.springframework.webflow.execution.RequestContext; -import org.springframework.webflow.executor.FlowExecutor; -import org.springframework.webflow.test.MockExternalContext; - -public class EnableScopesBeanDefinitionParserTests extends TestCase { - - private ClassPathXmlApplicationContext context; - - private FlowExecutor executor; - - public void setUp() { - context = new ClassPathXmlApplicationContext("org/springframework/webflow/config/enable-flow-scopes.xml"); - executor = (FlowExecutor) context.getBean("flowExecutor"); - } - - public void testExecute() { - MockExternalContext context = new MockExternalContext(); - } - - public static class ConfigurationListener extends FlowExecutionListenerAdapter { - public void sessionEnded(RequestContext context, FlowSession session, AttributeMap output) { - assertNotNull(session.getScope().get("user")); - } - } - -} diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java index 40e489ba..94970a6c 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java @@ -7,11 +7,12 @@ import org.springframework.binding.convert.ConversionExecutor; import org.springframework.binding.convert.ConversionService; import org.springframework.binding.convert.support.DefaultConversionService; import org.springframework.binding.expression.Expression; +import org.springframework.binding.expression.ExpressionParser; +import org.springframework.binding.format.FormatterRegistry; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.io.ResourceLoader; import org.springframework.webflow.engine.builder.ViewFactoryCreator; import org.springframework.webflow.engine.builder.support.FlowBuilderServices; -import org.springframework.webflow.execution.Action; import org.springframework.webflow.execution.ViewFactory; import org.springframework.webflow.mvc.view.MvcViewFactoryCreator; @@ -42,11 +43,8 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase { public static class TestViewFactoryCreator implements ViewFactoryCreator { - public Action createRenderViewAction(Expression viewId, ResourceLoader viewResourceLoader) { - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public ViewFactory createViewFactory(Expression viewId, ResourceLoader viewResourceLoader) { + public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry, ResourceLoader resourceLoader) { throw new UnsupportedOperationException("Auto-generated method stub"); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewFactoryTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewFactoryTests.java index 487830a8..a688c30f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewFactoryTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewFactoryTests.java @@ -25,7 +25,6 @@ import org.springframework.web.servlet.ViewResolver; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.View; import org.springframework.webflow.execution.ViewFactory; -import org.springframework.webflow.mvc.view.MvcViewFactoryCreator; import org.springframework.webflow.test.GeneratedFlowExecutionKey; import org.springframework.webflow.test.MockExternalContext; import org.springframework.webflow.test.MockRequestContext; @@ -51,7 +50,7 @@ public class MvcViewFactoryTests extends TestCase { } }; Expression viewId = new StaticExpression("myview.jsp"); - ViewFactory viewFactory = creator.createViewFactory(viewId, viewResourceLoader); + ViewFactory viewFactory = creator.createViewFactory(viewId, null, null, viewResourceLoader); MockRequestContext context = new MockRequestContext(); MockExternalContext externalContext = new MockExternalContext(); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -71,7 +70,7 @@ public class MvcViewFactoryTests extends TestCase { creator.setApplicationContext(context); creator.setViewResolvers(Collections.singletonList(viewResolver)); Expression viewId = new StaticExpression("myview"); - ViewFactory viewFactory = creator.createViewFactory(viewId, null); + ViewFactory viewFactory = creator.createViewFactory(viewId, null, null, null); MockRequestContext context = new MockRequestContext(); MockExternalContext externalContext = new MockExternalContext(); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -98,7 +97,7 @@ public class MvcViewFactoryTests extends TestCase { } }; Expression viewId = new StaticExpression("myview.jsp"); - ViewFactory viewFactory = creator.createViewFactory(viewId, viewResourceLoader); + ViewFactory viewFactory = creator.createViewFactory(viewId, null, null, viewResourceLoader); MockRequestContext context = new MockRequestContext(); MockExternalContext externalContext = new MockExternalContext(); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -130,7 +129,7 @@ public class MvcViewFactoryTests extends TestCase { } }; Expression viewId = new StaticExpression("myview.jsp"); - ViewFactory viewFactory = creator.createViewFactory(viewId, viewResourceLoader); + ViewFactory viewFactory = creator.createViewFactory(viewId, null, null, viewResourceLoader); MockRequestContext context = new MockRequestContext(); MockExternalContext externalContext = new MockExternalContext(); MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java index 2c27a591..3b3f194c 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java @@ -11,6 +11,9 @@ import javax.servlet.http.HttpServletResponse; import junit.framework.TestCase; import org.springframework.binding.expression.support.StaticExpression; +import org.springframework.binding.format.factories.DateFormatterFactory; +import org.springframework.binding.format.factories.NumberFormatterFactory; +import org.springframework.binding.format.impl.FormatterRegistryImpl; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; @@ -25,6 +28,13 @@ public class MvcViewTests extends TestCase { private Map model; + private FormatterRegistryImpl formatterRegistry = new FormatterRegistryImpl(); + + public void setUp() { + formatterRegistry.registerFormatter(new NumberFormatterFactory()); + formatterRegistry.registerFormatter(new DateFormatterFactory()); + } + public void testRender() throws Exception { MockRequestContext context = new MockRequestContext(); context.getRequestScope().put("foo", "bar"); @@ -39,6 +49,7 @@ public class MvcViewTests extends TestCase { context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); org.springframework.web.servlet.View mvcView = new MockView(); MvcView view = new MvcView(mvcView, context); + view.setFormatterRegistry(formatterRegistry); view.render(); assertTrue(renderCalled); assertEquals("bar", model.get("foo")); @@ -65,6 +76,7 @@ public class MvcViewTests extends TestCase { context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); org.springframework.web.servlet.View mvcView = new MockView(); MvcView view = new MvcView(mvcView, context); + view.setFormatterRegistry(formatterRegistry); view.render(); assertEquals(context.getFlowScope().get("bindBean"), model.get("bindBean")); BindingModel bm = (BindingModel) model.get(BindingResult.MODEL_KEY_PREFIX + "bindBean"); @@ -96,6 +108,7 @@ public class MvcViewTests extends TestCase { context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); org.springframework.web.servlet.View mvcView = new MockView(); MvcView view = new MvcView(mvcView, context); + view.setFormatterRegistry(formatterRegistry); view.resume(); assertTrue(view.eventSignaled()); assertEquals("submit", view.getEvent().getId()); @@ -118,6 +131,7 @@ public class MvcViewTests extends TestCase { context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); org.springframework.web.servlet.View mvcView = new MockView(); MvcView view = new MvcView(mvcView, context); + view.setFormatterRegistry(formatterRegistry); view.resume(); assertTrue(view.eventSignaled()); assertEquals("submit", view.getEvent().getId());