From 7c151fd40d7b7160f887cb224ef7f538fbdf5c6f Mon Sep 17 00:00:00 2001 From: Jeremy Grelle Date: Thu, 13 Mar 2008 21:46:30 +0000 Subject: [PATCH] SWF-527 - org.springframework.faces.webflow.FlowVariableResolver not working with JDK1.4 --- .../src/main/java/META-INF/faces-config.xml | 1 + .../faces/webflow/FlowVariableResolver.java | 2 -- .../SpringBeanWebFlowVariableResolver.java | 34 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 spring-faces/src/main/java/org/springframework/faces/webflow/SpringBeanWebFlowVariableResolver.java diff --git a/spring-faces/src/main/java/META-INF/faces-config.xml b/spring-faces/src/main/java/META-INF/faces-config.xml index e279da38..1f0c9515 100644 --- a/spring-faces/src/main/java/META-INF/faces-config.xml +++ b/spring-faces/src/main/java/META-INF/faces-config.xml @@ -9,6 +9,7 @@ org.springframework.faces.webflow.FlowActionListener org.springframework.faces.model.SelectionTrackingActionListener org.springframework.faces.webflow.FlowVariableResolver + org.springframework.faces.webflow.SpringBeanWebFlowVariableResolver org.springframework.faces.webflow.FlowPropertyResolver org.springframework.faces.webflow.FlowViewHandler diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java index 59cb406e..1b0aed22 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowVariableResolver.java @@ -23,7 +23,6 @@ import org.springframework.util.ClassUtils; import org.springframework.webflow.expression.el.ImplicitFlowVariableELResolver; import org.springframework.webflow.expression.el.RequestContextELResolver; import org.springframework.webflow.expression.el.ScopeSearchingELResolver; -import org.springframework.webflow.expression.el.SpringBeanWebFlowELResolver; import org.springframework.webflow.expression.el.SpringSecurityELResolver; /** @@ -42,7 +41,6 @@ public class FlowVariableResolver extends ELDelegatingVariableResolver { if (ClassUtils.isPresent("org.springframework.security.context.SecurityContextHolder")) { composite.add(new SpringSecurityELResolver()); } - composite.add(new SpringBeanWebFlowELResolver()); } public FlowVariableResolver(VariableResolver nextResolver) { diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/SpringBeanWebFlowVariableResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/SpringBeanWebFlowVariableResolver.java new file mode 100644 index 00000000..4880c760 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/SpringBeanWebFlowVariableResolver.java @@ -0,0 +1,34 @@ +package org.springframework.faces.webflow; + +import javax.faces.context.FacesContext; +import javax.faces.el.VariableResolver; + +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.support.StaticListableBeanFactory; +import org.springframework.web.jsf.SpringBeanVariableResolver; +import org.springframework.webflow.execution.RequestContext; +import org.springframework.webflow.execution.RequestContextHolder; + +/** + * JSF 1.1 variable resolver for Spring Beans accessible to the flow's local bean factory. + * @author Jeremy Grelle + */ +public class SpringBeanWebFlowVariableResolver extends SpringBeanVariableResolver { + + private static final BeanFactory EMPTY_BEAN_FACTORY = new StaticListableBeanFactory(); + + public SpringBeanWebFlowVariableResolver(VariableResolver originalVariableResolver) { + super(originalVariableResolver); + } + + protected BeanFactory getBeanFactory(FacesContext facesContext) { + RequestContext requestContext = RequestContextHolder.getRequestContext(); + if (requestContext != null && requestContext.getActiveFlow().getBeanFactory() != null) { + BeanFactory factory = requestContext.getActiveFlow().getBeanFactory(); + return factory; + } else { + return EMPTY_BEAN_FACTORY; + } + } + +}