This commit is contained in:
Keith Donald
2008-04-04 22:14:06 +00:00
parent ec2c4ba105
commit ee597b7995
63 changed files with 866 additions and 542 deletions

View File

@@ -32,6 +32,14 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataMode
private List selections = new ArrayList();
public ManySelectionTrackingListDataModel() {
super();
}
public ManySelectionTrackingListDataModel(List list) {
super(list);
}
public List getSelections() {
return selections;
}

View File

@@ -31,6 +31,14 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataModel
private List selections = new ArrayList();
public OneSelectionTrackingListDataModel() {
super();
}
public OneSelectionTrackingListDataModel(List list) {
super(list);
}
public List getSelections() {
return selections;
}

View File

@@ -31,8 +31,9 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.binding.expression.Expression;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ContextResource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.faces.ui.AjaxViewRoot;
import org.springframework.webflow.context.ExternalContext;
import org.springframework.webflow.execution.RequestContext;
@@ -56,13 +57,10 @@ public class JsfViewFactory implements ViewFactory {
private final Expression viewIdExpression;
private final ResourceLoader resourceLoader;
private final Lifecycle lifecycle;
public JsfViewFactory(Expression viewIdExpression, ResourceLoader resourceLoader, Lifecycle lifecycle) {
public JsfViewFactory(Expression viewIdExpression, Lifecycle lifecycle) {
this.viewIdExpression = viewIdExpression;
this.resourceLoader = resourceLoader;
this.lifecycle = lifecycle;
}
@@ -141,8 +139,16 @@ public class JsfViewFactory implements ViewFactory {
if (viewId.startsWith("/")) {
return viewId;
} else {
ContextResource viewResource = (ContextResource) resourceLoader.getResource(viewId);
return viewResource.getPathWithinContext();
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(viewId);
if (!(viewResource instanceof ContextResource)) {
throw new IllegalStateException(
"A ContextResource is required to get relative view paths within this context");
}
return ((ContextResource) viewResource).getPathWithinContext();
}
}

View File

@@ -20,7 +20,6 @@ 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;
@@ -36,8 +35,8 @@ public class JsfViewFactoryCreator implements ViewFactoryCreator {
private Lifecycle lifecycle;
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry, ResourceLoader resourceLoader) {
return new JsfViewFactory(viewIdExpression, resourceLoader, getLifecycle());
FormatterRegistry formatterRegistry) {
return new JsfViewFactory(viewIdExpression, getLifecycle());
}
public String getViewIdByConvention(String viewStateId) {

View File

@@ -70,8 +70,8 @@ public class JsfFinalResponseActionTests extends TestCase {
jsfMock.facesContext().setViewRoot(null);
jsfMock.facesContext().getApplication().setViewHandler(viewHandler);
lifecycle = new TestLifecycle(jsfMock.lifecycle());
factory = new JsfViewFactory(parser.parseExpression("#{'" + VIEW_ID + "'}", new FluentParserContext().template()
.evaluate(RequestContext.class).expectResult(String.class)), null, lifecycle);
factory = new JsfViewFactory(parser.parseExpression("#{'" + VIEW_ID + "'}", new FluentParserContext()
.template().evaluate(RequestContext.class).expectResult(String.class)), lifecycle);
RequestContextHolder.setRequestContext(context);
MockExternalContext ext = new MockExternalContext();
ext.setNativeContext(new MockServletContext());

View File

@@ -94,7 +94,7 @@ public class JsfViewFactoryTests extends TestCase {
lifecycle = new NoExecutionLifecycle(jsfMock.lifecycle());
factory = new JsfViewFactory(parser.parseExpression(VIEW_ID, new FluentParserContext().template().evaluate(
RequestContext.class).expectResult(String.class)), null, lifecycle);
RequestContext.class).expectResult(String.class)), lifecycle);
UIViewRoot newRoot = new UIViewRoot();
newRoot.setViewId(VIEW_ID);
@@ -117,7 +117,7 @@ public class JsfViewFactoryTests extends TestCase {
lifecycle = new NoExecutionLifecycle(jsfMock.lifecycle());
factory = new JsfViewFactory(parser.parseExpression(VIEW_ID, new FluentParserContext().template().evaluate(
RequestContext.class).expectResult(String.class)), null, lifecycle);
RequestContext.class).expectResult(String.class)), lifecycle);
UIViewRoot existingRoot = new UIViewRoot();
existingRoot.setViewId(VIEW_ID);
@@ -141,7 +141,7 @@ public class JsfViewFactoryTests extends TestCase {
lifecycle = new NoExecutionLifecycle(jsfMock.lifecycle());
factory = new JsfViewFactory(parser.parseExpression(VIEW_ID, new FluentParserContext().template().evaluate(
RequestContext.class).expectResult(String.class)), null, lifecycle);
RequestContext.class).expectResult(String.class)), lifecycle);
UIViewRoot existingRoot = new UIViewRoot();
existingRoot.setViewId(VIEW_ID);
@@ -169,7 +169,7 @@ public class JsfViewFactoryTests extends TestCase {
lifecycle = new NoExecutionLifecycle(jsfMock.lifecycle());
factory = new JsfViewFactory(parser.parseExpression(VIEW_ID, new FluentParserContext().template().evaluate(
RequestContext.class).expectResult(String.class)), null, lifecycle);
RequestContext.class).expectResult(String.class)), lifecycle);
UIViewRoot newRoot = new UIViewRoot();
newRoot.setViewId(VIEW_ID);