From 82b6709a71b64c80825decdbb7403ccff201bd19 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Thu, 6 Mar 2008 21:29:45 +0000 Subject: [PATCH] SWF-483 Added extension to the ViewFacotryCreator interface, createViewIdByConvention, to obtain the default view id for a view state id --- .../webflow/engine/builder/ViewFactoryCreator.java | 6 ++++++ .../webflow/engine/builder/xml/XmlFlowBuilder.java | 7 +------ .../springframework/webflow/mvc/MvcViewFactoryCreator.java | 5 +++++ .../webflow/test/MockViewFactoryCreator.java | 4 ++++ 4 files changed, 16 insertions(+), 6 deletions(-) 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 3c6ce9ca..04b5c3b1 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 @@ -35,4 +35,10 @@ public interface ViewFactoryCreator { */ public ViewFactory createViewFactory(Expression viewId, ResourceLoader viewResourceLoader); + /** + * Create the default id of the view to render in the provided view state by convention. + * @param viewStateId the view state id + * @return the default view id + */ + public String createViewIdByConvention(String viewStateId); } 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 fa1e26c4..5d2f7776 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 @@ -593,7 +593,7 @@ public class XmlFlowBuilder extends AbstractFlowBuilder implements ResourceHolde if (endState) { return null; } else { - encodedView = createViewId(parseId(element)); + encodedView = getLocalContext().getViewFactoryCreator().createViewIdByConvention(parseId(element)); Expression viewName = getExpressionParser().parseExpression(encodedView, new ParserContextImpl().eval(RequestContext.class).expect(String.class)); return getLocalContext().getViewFactoryCreator().createViewFactory(viewName, @@ -620,11 +620,6 @@ public class XmlFlowBuilder extends AbstractFlowBuilder implements ResourceHolde } } - // TODO - make configurable - private String createViewId(String viewStateId) { - return viewStateId + ".xhtml"; - } - 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/MvcViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/MvcViewFactoryCreator.java index 97737b2c..8bd3e754 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/MvcViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/MvcViewFactoryCreator.java @@ -62,6 +62,11 @@ public class MvcViewFactoryCreator implements ViewFactoryCreator, ApplicationCon } } + public String createViewIdByConvention(String viewStateId) { + // TODO - make configurable + return viewStateId + ".jsp"; + } + /** * Sets the view resolvers that will be used to resolve views selected by flows. If multiple resolvers are to be * used, the resolvers should be ordered in the manner they should be applied. 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 0d864b66..d501a102 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 @@ -40,6 +40,10 @@ class MockViewFactoryCreator implements ViewFactoryCreator { return new MockViewFactory(viewId); } + public String createViewIdByConvention(String viewStateId) { + return viewStateId; + } + /** * Returns a Mock View implementation that simply holds the evaluated view identifier. * @author Keith Donald