moved history from view-state to transition
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -351,7 +351,7 @@ Actions to execute immediately before view rendering.
|
||||
<xsd:group ref="actionTypes" maxOccurs="unbounded" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="transition" type="bindableTransition" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="transition" type="viewTransition" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
@@ -471,47 +471,6 @@ The model object this view is bound to. Typically used as the source of form fi
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="history">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Sets the history policy for this view state. The default is 'preserve', which allows back-tracking to this state after it exits.
|
||||
'discard' prevents back-tracking to this state, and 'invalidate' prevents back-tracking to this state and any previously entered view-state.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="preserve">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Upon exiting this view state, preserve state history to allow back-tracking to this point.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
<xsd:enumeration value="discard">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Upon exiting this view state, discard state history to prevent back-tracking to this point.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
<xsd:enumeration value="invalidate">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Upon exiting this view state, invalidate all view state history to prevent back-tracking to any previous point.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="decision-state">
|
||||
@@ -948,7 +907,7 @@ Transitions shared by all states and eligible for execution if no transition ass
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="transition" type="bindableTransition" maxOccurs="unbounded">
|
||||
<xsd:element name="transition" type="viewTransition" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
@@ -1428,7 +1387,7 @@ If no value is specified, this transition acts as a simple event handler and wil
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="bindableTransition">
|
||||
<xsd:complexType name="viewTransition">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="transition">
|
||||
<xsd:attribute name="bind" type="xsd:boolean">
|
||||
@@ -1440,6 +1399,47 @@ Indicates whether model binding should occur before this transition executes. De
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="history">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Sets the state history policy for this transition. The default is 'preserve', which allows back-tracking to the current state after this transition executes.
|
||||
'discard' prevents back-tracking to the state, and 'invalidate' prevents back-tracking to the state as well as any previously entered view-state.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="preserve">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
When executing this transition, preserve state history to allow back-tracking to the current view-state.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
<xsd:enumeration value="discard">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
When executing this transition, discard state history to prevent back-tracking to the current view-state.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
<xsd:enumeration value="invalidate">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
When executing this transition, invalidate all state history to prevent back-tracking to previously entered view-states.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
Reference in New Issue
Block a user