added history attribute to view-state and allow attribute elements in actions

This commit is contained in:
Scott Andrews
2008-04-04 21:14:00 +00:00
parent b31929d49e
commit aab006e7a4
4 changed files with 142 additions and 1 deletions

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.webflow.engine.model;
import java.util.LinkedList;
/**
* Model support for actions.
*
@@ -22,6 +24,8 @@ package org.springframework.webflow.engine.model;
*/
public abstract class AbstractActionModel extends AbstractModel {
private LinkedList attributes;
/**
* Actions are not mergeable
* @param model the model to test
@@ -38,4 +42,44 @@ public abstract class AbstractActionModel extends AbstractModel {
// not mergeable
}
/**
* @return the attributes
*/
public LinkedList getAttributes() {
return attributes;
}
/**
* @param attributes the attributes to set
*/
public void setOutputs(LinkedList attributes) {
this.attributes = attributes;
}
/**
* @param attribute the attribute to add
*/
public void addAttribute(AttributeModel attribute) {
if (attribute == null) {
return;
}
if (attributes == null) {
attributes = new LinkedList();
}
attributes.add(attribute);
}
/**
* @param attributes the attributes to add
*/
public void addAttributes(LinkedList attributes) {
if (attributes == null || attributes.isEmpty()) {
return;
}
if (this.attributes == null) {
this.attributes = new LinkedList();
}
this.attributes.addAll(attributes);
}
}

View File

@@ -30,6 +30,7 @@ public class ViewStateModel extends AbstractTransitionableStateModel {
private String redirect;
private String popup;
private String model;
private String history;
private LinkedList vars;
private LinkedList onRenderActions;
@@ -62,6 +63,7 @@ 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));
}
@@ -138,6 +140,24 @@ 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
*/

View File

@@ -531,16 +531,20 @@ public class XmlFlowModelBuilder implements FlowModelBuilder {
EvaluateModel evaluate = new EvaluateModel(element.getAttribute("expression"));
evaluate.setResult(element.getAttribute("result"));
evaluate.setResultType(element.getAttribute("result-type"));
evaluate.addAttributes(parseAttributes(element));
return evaluate;
}
private RenderModel parseRender(Element element) {
return new RenderModel(element.getAttribute("fragments"));
RenderModel render = new RenderModel(element.getAttribute("fragments"));
render.addAttributes(parseAttributes(element));
return render;
}
private SetModel parseSet(Element element) {
SetModel set = new SetModel(element.getAttribute("name"), element.getAttribute("value"));
set.setType(element.getAttribute("type"));
set.addAttributes(parseAttributes(element));
return set;
}
@@ -564,6 +568,7 @@ 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));

View File

@@ -508,6 +508,45 @@ 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[
The history of the view state should be preserved when the view state exits to support back-tracking.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="preserve">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="discard">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The history of the view state should be discarded when the view state exits to prevent back-tracking.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="invalidate">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The history of the view state and all previous view state should be invalidated to completely restrict back tracking.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="decision-state">
@@ -1092,6 +1131,17 @@ Evaluates an expression against the flow request context.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="attribute" type="attribute" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
An attribute for the action.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="expression" type="expression" use="required">
<xsd:annotation>
<xsd:documentation>
@@ -1132,6 +1182,17 @@ Multiple fragments may be specified using a comma delimiter.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="attribute" type="attribute" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
An attribute for the action.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="fragments" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
@@ -1153,6 +1214,17 @@ Sets an attribute value in a scope.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="attribute" type="attribute" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
An attribute for the action.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="expression" use="required">
<xsd:annotation>
<xsd:documentation>