diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/DelegatingFlowVariableResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/DelegatingFlowVariableResolver.java
index ab029256..8b7359f6 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/DelegatingFlowVariableResolver.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/DelegatingFlowVariableResolver.java
@@ -66,20 +66,20 @@ public class DelegatingFlowVariableResolver extends VariableResolver {
* chain.
*/
public Object resolveVariable(FacesContext context, String name) throws EvaluationException {
- FlowExecution execution = FlowExecutionHolderUtils.getRequiredCurrentFlowExecution(context);
- // try flash/flow/conversation
- if (execution.getActiveSession().getFlashMap().contains(name)) {
- return execution.getActiveSession().getFlashMap().get(name);
- }
- else if (execution.getActiveSession().getScope().contains(name)) {
- return execution.getActiveSession().getScope().get(name);
- }
- else if (execution.getConversationScope().contains(name)) {
- return execution.getConversationScope().get(name);
- }
- else {
- // neither found a value, delegate to next resolver in the chain
- return resolverDelegate.resolveVariable(context, name);
+ FlowExecution execution = FlowExecutionHolderUtils.getCurrentFlowExecution(context);
+ if (execution != null) {
+ // try flash/flow/conversation
+ if (execution.getActiveSession().getFlashMap().contains(name)) {
+ return execution.getActiveSession().getFlashMap().get(name);
+ }
+ else if (execution.getActiveSession().getScope().contains(name)) {
+ return execution.getActiveSession().getScope().get(name);
+ }
+ else if (execution.getConversationScope().contains(name)) {
+ return execution.getConversationScope().get(name);
+ }
}
+ // no flow execution bound or flow execution attribute found with that name - delegate
+ return resolverDelegate.resolveVariable(context, name);
}
}
\ No newline at end of file
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java
index 33ed8bcf..77772f81 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java
@@ -60,24 +60,38 @@ public class FlowExecutionHolderUtils {
}
/**
- * Returns the current flow execution holder for the given faces context.
+ * Returns the current flow execution in the given faces context.
* @param context faces context
- * @return the flow execution holder or null if none set
- * @throws EvaluationException if no flow execution was bound
+ * @return the flow execution or null if no execution is bound
*/
- public static FlowExecution getRequiredCurrentFlowExecution(FacesContext context) throws EvaluationException {
+ public static FlowExecution getCurrentFlowExecution(FacesContext context) {
FlowExecutionHolder holder = getFlowExecutionHolder(context);
if (holder != null) {
return holder.getFlowExecution();
- }
- else {
- throw new EvaluationException(
- "FlowExecution is not bound to current thread context - has the flow ended or expired?");
+ } else {
+ return null;
}
}
+ /**
+ * Returns the current required flow execution in the given faces context.
+ * @param context faces context
+ * @return the flow execution
+ * @throws EvaluationException if no flow execution was bound
+ */
+ public static FlowExecution getRequiredCurrentFlowExecution(FacesContext context) throws EvaluationException {
+ FlowExecution execution = getCurrentFlowExecution(context);
+ if (execution != null) {
+ return execution;
+ }
+ else {
+ throw new EvaluationException("No current FlowExecution bound to the Faces Context "
+ + "- was the current flow execution restored before any components referenced it? "
+ + "Has the flow execution ended or expired?");
+ }
+ }
+
private static String getFlowExecutionHolderKey() {
return FlowExecutionHolder.class.getName();
}
-
}
\ No newline at end of file