addressed cyclical dependency with view package

This commit is contained in:
Keith Donald
2008-04-25 01:02:09 +00:00
parent 3db1aabd4c
commit a3b8d2fae7
13 changed files with 30 additions and 30 deletions

View File

@@ -39,7 +39,7 @@ public class JsfViewFactoryCreator implements ViewFactoryCreator {
return new JsfViewFactory(viewIdExpression, getLifecycle());
}
public String getViewNameByConvention(String viewStateId) {
public String getViewIdByConvention(String viewStateId) {
return viewStateId + FACELETS_EXTENSION;
}

View File

@@ -66,7 +66,7 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
throw new UnsupportedOperationException("Auto-generated method stub");
}
public String getViewNameByConvention(String viewStateId) {
public String getViewIdByConvention(String viewStateId) {
return viewStateId;
}

View File

@@ -30,12 +30,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 viewName an expression that resolves the name of the view template
* @param viewId an expression that resolves the id of the view to render
* @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 viewName, ExpressionParser expressionParser,
public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry);
/**
@@ -43,5 +43,5 @@ public interface ViewFactoryCreator {
* @param viewStateId the view state id
* @return the default view id
*/
public String getViewNameByConvention(String viewStateId);
public String getViewIdByConvention(String viewStateId);
}

View File

@@ -588,7 +588,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
if (endState) {
return null;
} else {
view = getLocalContext().getViewFactoryCreator().getViewNameByConvention(stateId);
view = getLocalContext().getViewFactoryCreator().getViewIdByConvention(stateId);
Expression viewId = getLocalContext().getExpressionParser().parseExpression(view,
new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class));
return createViewFactory(viewId);

View File

@@ -41,16 +41,16 @@ public class DelegatingFlowViewResolver implements FlowViewResolver {
this.viewResolvers = viewResolvers;
}
public View resolveView(String viewName, RequestContext context) {
public View resolveView(String viewId, RequestContext context) {
for (Iterator it = viewResolvers.iterator(); it.hasNext();) {
ViewResolver viewResolver = (ViewResolver) it.next();
try {
View view = viewResolver.resolveViewName(viewName, context.getExternalContext().getLocale());
View view = viewResolver.resolveViewName(viewId, context.getExternalContext().getLocale());
if (view != null) {
return view;
}
} catch (Exception e) {
throw new IllegalStateException("Exception resolving view with name '" + viewName + "'", e);
throw new IllegalStateException("Exception resolving view with name '" + viewId + "'", e);
}
}
return null;

View File

@@ -34,15 +34,15 @@ public class InternalResourceFlowViewResolver implements FlowViewResolver {
private static final boolean JSTL_PRESENT = ClassUtils.isPresent("javax.servlet.jsp.jstl.fmt.LocalizationContext");
public View resolveView(String viewName, RequestContext context) {
if (viewName.startsWith("/")) {
return getViewInternal(viewName, context, context.getActiveFlow().getApplicationContext());
public View resolveView(String viewId, RequestContext context) {
if (viewId.startsWith("/")) {
return getViewInternal(viewId, context, context.getActiveFlow().getApplicationContext());
} else {
ApplicationContext flowContext = context.getActiveFlow().getApplicationContext();
if (flowContext == null) {
throw new IllegalStateException("A Flow ApplicationContext is required to resolve Flow View Resources");
}
Resource viewResource = flowContext.getResource(viewName);
Resource viewResource = flowContext.getResource(viewId);
if (!(viewResource instanceof ContextResource)) {
throw new IllegalStateException(
"A ContextResource is required to get relative view paths within this context");

View File

@@ -96,18 +96,18 @@ public class MvcViewFactoryCreator implements ViewFactoryCreator {
this.flowViewResolver = flowViewResolver;
}
public ViewFactory createViewFactory(Expression viewName, ExpressionParser expressionParser,
public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry) {
if (environment == null || environment == MvcEnvironment.SERVLET) {
return new ServletMvcViewFactory(viewName, flowViewResolver, expressionParser, formatterRegistry);
return new ServletMvcViewFactory(viewId, flowViewResolver, expressionParser, formatterRegistry);
} else if (environment == MvcEnvironment.PORTLET) {
return new PortletMvcViewFactory(viewName, flowViewResolver, expressionParser, formatterRegistry);
return new PortletMvcViewFactory(viewId, flowViewResolver, expressionParser, formatterRegistry);
} else {
throw new IllegalStateException("Environment not supported " + environment);
}
}
public String getViewNameByConvention(String viewStateId) {
public String getViewIdByConvention(String viewStateId) {
if (flowViewResolver instanceof DelegatingFlowViewResolver) {
return viewStateId;
} else {

View File

@@ -31,9 +31,9 @@ import org.springframework.webflow.mvc.view.FlowViewResolver;
*/
public class PortletMvcViewFactory extends AbstractMvcViewFactory {
public PortletMvcViewFactory(Expression viewName, FlowViewResolver viewResolver, ExpressionParser expressionParser,
public PortletMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry) {
super(viewName, viewResolver, expressionParser, formatterRegistry);
super(viewId, viewResolver, expressionParser, formatterRegistry);
}
protected AbstractMvcView createMvcView(View view, RequestContext context) {

View File

@@ -31,9 +31,9 @@ import org.springframework.webflow.mvc.view.FlowViewResolver;
*/
public class ServletMvcViewFactory extends AbstractMvcViewFactory {
public ServletMvcViewFactory(Expression viewName, FlowViewResolver viewResolver, ExpressionParser expressionParser,
public ServletMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry) {
super(viewName, viewResolver, expressionParser, formatterRegistry);
super(viewId, viewResolver, expressionParser, formatterRegistry);
}
protected AbstractMvcView createMvcView(View view, RequestContext context) {

View File

@@ -29,7 +29,7 @@ import org.springframework.webflow.execution.ViewFactory;
*/
public abstract class AbstractMvcViewFactory implements ViewFactory {
private Expression viewName;
private Expression viewId;
private FlowViewResolver viewResolver;
@@ -37,9 +37,9 @@ public abstract class AbstractMvcViewFactory implements ViewFactory {
private FormatterRegistry formatterRegistry;
public AbstractMvcViewFactory(Expression viewName, FlowViewResolver viewResolver,
ExpressionParser expressionParser, FormatterRegistry formatterRegistry) {
this.viewName = viewName;
public AbstractMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry) {
this.viewId = viewId;
this.viewResolver = viewResolver;
this.expressionParser = expressionParser;
this.formatterRegistry = formatterRegistry;
@@ -54,8 +54,8 @@ public abstract class AbstractMvcViewFactory implements ViewFactory {
}
public View getView(RequestContext context) {
String viewName = (String) this.viewName.getValue(context);
org.springframework.web.servlet.View view = viewResolver.resolveView(viewName, context);
String viewId = (String) this.viewId.getValue(context);
org.springframework.web.servlet.View view = viewResolver.resolveView(viewId, context);
return createMvcView(view, context);
}

View File

@@ -26,5 +26,5 @@ import org.springframework.webflow.execution.RequestContext;
* @see ViewResolver
*/
public interface FlowViewResolver {
public View resolveView(String viewName, RequestContext context);
public View resolveView(String viewId, RequestContext context);
}

View File

@@ -39,7 +39,7 @@ class MockViewFactoryCreator implements ViewFactoryCreator {
return new MockViewFactory(viewIdExpression);
}
public String getViewNameByConvention(String viewStateId) {
public String getViewIdByConvention(String viewStateId) {
return viewStateId;
}

View File

@@ -49,7 +49,7 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public String getViewNameByConvention(String viewStateId) {
public String getViewIdByConvention(String viewStateId) {
return viewStateId;
}