Added extension to the ViewFacotryCreator interface, createViewIdByConvention, to obtain the default view id for a view state id
This commit is contained in:
Scott Andrews
2008-03-06 21:29:45 +00:00
parent aead4222cd
commit 82b6709a71
4 changed files with 16 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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.

View File

@@ -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