delegating should proceed to next resolver if no execution bound
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 <code>null</code> if none set
|
||||
* @throws EvaluationException if no flow execution was bound
|
||||
* @return the flow execution or <code>null</code> 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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user