diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java index 646d7c0a..cb2e23f3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java @@ -22,6 +22,7 @@ import java.util.Map; import org.springframework.core.style.ToStringCreator; import org.springframework.util.Assert; +import org.springframework.webflow.definition.TransitionDefinition; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.FlowExecutionException; import org.springframework.webflow.execution.RequestContext; @@ -59,12 +60,6 @@ public class ViewState extends TransitionableState { */ private Boolean redirect; - /** - * An enum indicating the history behavior of this view-state. Used to configure back-tracking policies. Default is - * {@link History#PRESERVE}. - */ - private History history = History.PRESERVE; - /** * Whether or not the view should render as a popup. */ @@ -152,24 +147,6 @@ public class ViewState extends TransitionableState { this.popup = popup; } - /** - * Returns the history behavior of this view-state. Used to configure back-tracking policies. Default is - * {@link History#PRESERVE}. - * @return the history - */ - public History getHistory() { - return history; - } - - /** - * Sets the history behavior of this view state. Used to configure back-tracking policies. Default is - * {@link History#PRESERVE}. - * @param history the history - */ - public void setHistory(History history) { - this.history = history; - } - /** * Returns the view factory. */ @@ -226,13 +203,7 @@ public class ViewState extends TransitionableState { public void exit(RequestControlContext context) { super.exit(context); - if (history == History.PRESERVE) { - context.updateCurrentFlowExecutionSnapshot(); - } else if (history == History.DISCARD) { - context.removeCurrentFlowExecutionSnapshot(); - } else if (history == History.INVALIDATE) { - context.removeAllFlowExecutionSnapshots(); - } + updateHistory(context); destroyVariables(context); } @@ -287,6 +258,18 @@ public class ViewState extends TransitionableState { } } + private void updateHistory(RequestControlContext context) { + TransitionDefinition t = context.getCurrentTransition(); + History history = (History) t.getAttributes().get("history"); + if (history == null || history == History.PRESERVE) { + context.updateCurrentFlowExecutionSnapshot(); + } else if (history == History.DISCARD) { + context.removeCurrentFlowExecutionSnapshot(); + } else if (history == History.INVALIDATE) { + context.removeAllFlowExecutionSnapshots(); + } + } + private void destroyVariables(RequestContext context) { Iterator it = variables.values().iterator(); while (it.hasNext()) { @@ -302,7 +285,7 @@ public class ViewState extends TransitionableState { protected void appendToString(ToStringCreator creator) { super.appendToString(creator); creator.append("viewFactory", viewFactory).append("variables", variables).append("redirect", redirect).append( - "popup", popup).append("history", history); + "popup", popup); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java index 119345d0..5b28218e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java @@ -23,7 +23,6 @@ import org.springframework.webflow.engine.DecisionState; import org.springframework.webflow.engine.EndState; import org.springframework.webflow.engine.Flow; import org.springframework.webflow.engine.FlowExecutionExceptionHandler; -import org.springframework.webflow.engine.History; import org.springframework.webflow.engine.State; import org.springframework.webflow.engine.SubflowAttributeMapper; import org.springframework.webflow.engine.SubflowState; @@ -82,14 +81,12 @@ public class FlowArtifactFactory { * @return the fully initialized view state instance */ public State createViewState(String id, Flow flow, ViewVariable[] variables, Action[] entryActions, - ViewFactory viewFactory, Boolean redirect, boolean popup, History history, Action[] renderActions, - Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, - AttributeMap attributes) { + ViewFactory viewFactory, Boolean redirect, boolean popup, Action[] renderActions, Transition[] transitions, + FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { ViewState viewState = new ViewState(flow, id, viewFactory); viewState.addVariables(variables); viewState.setRedirect(redirect); viewState.setPopup(popup); - viewState.setHistory(history); viewState.getRenderActionList().addAll(renderActions); configureCommonProperties(viewState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return viewState; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java index e2ac9829..46bdda8e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java @@ -524,10 +524,6 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { if (StringUtils.hasText(state.getPopup())) { popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup())).booleanValue(); } - History history = History.PRESERVE; - if (StringUtils.hasText(state.getHistory())) { - history = (History) fromStringTo(History.class).execute(state.getHistory()); - } MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); if (state.getModel() != null) { attributes.put("model", getLocalContext().getExpressionParser().parseExpression(state.getModel(), @@ -536,7 +532,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createViewState(state.getId(), flow, parseViewVariables(state.getVars()), parseActions(state.getOnEntryActions()), viewFactory, redirect, - popup, history, parseActions(state.getOnRenderActions()), parseTransitions(state.getTransitions()), + popup, parseActions(state.getOnRenderActions()), parseTransitions(state.getTransitions()), parseExceptionHandlers(state.getExceptionHandlers(), state.getTransitions()), parseActions(state.getOnExitActions()), attributes); } @@ -776,6 +772,9 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { if (StringUtils.hasText(transition.getBind())) { attributes.put("bind", fromStringTo(Boolean.class).execute(transition.getBind())); } + if (StringUtils.hasText(transition.getHistory())) { + attributes.put("history", fromStringTo(History.class).execute(transition.getHistory())); + } parseAndPutSecured(transition.getSecured(), attributes); return getLocalContext().getFlowArtifactFactory().createTransition(stateResolver, matchingCriteria, executionCriteria, attributes); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java index 6487fedd..9f30c2c3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java @@ -34,6 +34,7 @@ public class TransitionModel extends AbstractModel { private String onException; private String to; private String bind; + private String history; private LinkedList attributes; private SecuredModel secured; private LinkedList actions; @@ -57,6 +58,7 @@ public class TransitionModel extends AbstractModel { setOnException(merge(getOnException(), transition.getOnException())); setTo(merge(getTo(), transition.getTo())); setBind(merge(getBind(), transition.getBind())); + setHistory(merge(getHistory(), transition.getHistory())); setAttributes(merge(getAttributes(), transition.getAttributes())); setSecured((SecuredModel) merge(getSecured(), transition.getSecured())); setActions(merge(getActions(), transition.getActions(), false)); @@ -134,6 +136,24 @@ public class TransitionModel extends AbstractModel { } } + /** + * @return the history + */ + public String getHistory() { + return history; + } + + /** + * @param history the history to set + */ + public void setHistory(String history) { + if (StringUtils.hasText(history)) { + this.history = history; + } else { + this.history = null; + } + } + /** * @return the attributes */ diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java index a2f6f804..12126249 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java @@ -30,7 +30,6 @@ public class ViewStateModel extends AbstractTransitionableStateModel { private String redirect; private String popup; private String model; - private String history; private LinkedList vars; private LinkedList onRenderActions; @@ -63,7 +62,6 @@ public class ViewStateModel extends AbstractTransitionableStateModel { setRedirect(merge(getRedirect(), state.getRedirect())); setPopup(merge(getPopup(), state.getPopup())); setModel(merge(getModel(), state.getModel())); - setHistory(merge(getHistory(), state.getHistory())); setVars(merge(getVars(), state.getVars(), false)); setOnRenderActions(merge(getOnRenderActions(), state.getOnRenderActions(), false)); } @@ -140,24 +138,6 @@ public class ViewStateModel extends AbstractTransitionableStateModel { } } - /** - * @return the history - */ - public String getHistory() { - return history; - } - - /** - * @param history the history to set - */ - public void setHistory(String history) { - if (StringUtils.hasText(history)) { - this.history = history; - } else { - this.history = null; - } - } - /** * @return the vars */ diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java index 4fb689cf..0fe242a2 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java @@ -469,6 +469,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { transition.setTo(element.getAttribute("to")); transition.setOnException(element.getAttribute("on-exception")); transition.setBind(element.getAttribute("bind")); + transition.setHistory(element.getAttribute("history")); transition.setAttributes(parseAttributes(element)); transition.setSecured(parseSecured(element)); transition.setActions(parseActions(element)); @@ -575,7 +576,6 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { state.setRedirect(element.getAttribute("redirect")); state.setPopup(element.getAttribute("popup")); state.setModel(element.getAttribute("model")); - state.setHistory(element.getAttribute("history")); state.setVars(parseVars(element)); state.setOnRenderActions(parseOnRenderActions(element)); state.setAttributes(parseAttributes(element)); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/spring-webflow-2.0.xsd b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/spring-webflow-2.0.xsd index 5438f95d..97dd59c7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/spring-webflow-2.0.xsd +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/spring-webflow-2.0.xsd @@ -351,7 +351,7 @@ Actions to execute immediately before view rendering. - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -948,7 +907,7 @@ Transitions shared by all states and eligible for execution if no transition ass - + - + @@ -1440,6 +1399,47 @@ Indicates whether model binding should occur before this transition executes. De + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +