From 4645cff0b77f08c4e625e52fb81c9a0c76aaa3b9 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Mon, 2 Apr 2007 16:33:19 +0000 Subject: [PATCH] polishing --- .../jsf/FlowExecutionPropertyResolver.java | 36 +++++++++++++++---- .../jsf/FlowExecutionVariableResolver.java | 4 +-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionPropertyResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionPropertyResolver.java index 7b94f9b4..e49d3c2e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionPropertyResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionPropertyResolver.java @@ -34,6 +34,21 @@ import org.springframework.webflow.execution.FlowExecution; */ public class FlowExecutionPropertyResolver extends PropertyResolver { + /** + * The name of the special flash scope execution property. + */ + private static final String FLASH_SCOPE_PROPERTY = "flashScope"; + + /** + * The name of the special flow scope execution property. + */ + private static final String FLOW_SCOPE_PROPERTY = "flowScope"; + + /** + * The name of the special conversation scope execution property. + */ + private static final String CONVERSATION_SCOPE_PROPERTY = "conversationScope"; + /** * The standard property resolver to delegate to if this one doesn't apply. */ @@ -71,23 +86,27 @@ public class FlowExecutionPropertyResolver extends PropertyResolver { if (!(property instanceof String)) { throw new PropertyNotFoundException("Unable to get value from flow execution - key is non-String"); } - if ("flashScope".equals(property)) { + if (FLASH_SCOPE_PROPERTY.equals(property)) { return Map.class; - } else if ("flowScope".equals(property)) { + } else if (FLOW_SCOPE_PROPERTY.equals(property)) { return Map.class; - } else if ("conversationScope".equals(property)) { + } else if (CONVERSATION_SCOPE_PROPERTY.equals(property)) { return Map.class; } else { + // perform an attribute search FlowExecution execution = (FlowExecution)base; String attributeName = (String)property; + // try flash scope Object value = execution.getActiveSession().getFlashMap().get(attributeName); if (value != null) { return value.getClass(); } + // try flow scope value = execution.getActiveSession().getScope().get(attributeName); if (value != null) { return value.getClass(); } + // try conversation scope value = execution.getConversationScope().get(attributeName); if (value != null) { return value.getClass(); @@ -113,22 +132,26 @@ public class FlowExecutionPropertyResolver extends PropertyResolver { throw new PropertyNotFoundException("Unable to get value from flow execution - key is non-String"); } FlowExecution execution = (FlowExecution) base; - if ("flashScope".equals(property)) { + if (FLASH_SCOPE_PROPERTY.equals(property)) { return execution.getActiveSession().getScope().asMap(); - } else if ("flowScope".equals(property)) { + } else if (FLOW_SCOPE_PROPERTY.equals(property)) { return execution.getConversationScope().asMap(); - } else if ("conversationScope".equals(property)) { + } else if (CONVERSATION_SCOPE_PROPERTY.equals(property)) { return execution.getActiveSession().getFlashMap().asMap(); } else { + // perform an attribute search String attributeName = (String)property; + // try flash scope Object value = execution.getActiveSession().getFlashMap().get(attributeName); if (value != null) { return value; } + // try flow scope value = execution.getActiveSession().getScope().get(attributeName); if (value != null) { return value; } + // try conversation scope value = execution.getConversationScope().get(attributeName); if (value != null) { return value; @@ -171,6 +194,7 @@ public class FlowExecutionPropertyResolver extends PropertyResolver { } FlowExecution execution = (FlowExecution)base; String attributeName = (String)property; + // perform a search: flash, flow, conversation if (execution.getActiveSession().getFlashMap().contains(attributeName)) { execution.getActiveSession().getFlashMap().put(attributeName, value); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionVariableResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionVariableResolver.java index 134c3245..e1f69082 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionVariableResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionVariableResolver.java @@ -28,8 +28,8 @@ import org.springframework.webflow.execution.FlowExecution; * This class is designed to be used with a {@link FlowExecutionPropertyResolver}. * * This class is a more flexible alternative to the {@link FlowVariableResolver} which is expected to be used ONLY with - * a {@link FlowPropertyResolver} to resolve flow scope variables. It is more flexible because it provides access to any - * property accessible from a {@link FlowExecution} object. + * a {@link FlowPropertyResolver} to resolve flow scope variables ONLY. It is more flexible because it provides access + * to any scope structure of a {@link FlowExecution} object. * * @author Keith Donald */