view scope fixes

This commit is contained in:
Keith Donald
2008-03-31 20:42:53 +00:00
parent aabbc7d3bf
commit 3a27bdaac2
3 changed files with 21 additions and 17 deletions

View File

@@ -343,7 +343,13 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
listeners.fireStateEntering(context, newState);
FlowSessionImpl session = getActiveSessionInternal();
State previousState = (State) session.getState();
if (previousState != null && previousState.isViewState()) {
session.destroyViewScope();
}
session.setState(newState);
if (newState.isViewState()) {
session.initViewScope();
}
listeners.fireStateEntered(context, previousState);
}

View File

@@ -126,12 +126,6 @@ class FlowSessionImpl implements FlowSession, Externalizable {
return parent == null;
}
// package-private
Flow getFlow() {
return flow;
}
// custom serialization
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
@@ -148,6 +142,12 @@ class FlowSessionImpl implements FlowSession, Externalizable {
out.writeObject(parent);
}
// package-private
Flow getFlow() {
return flow;
}
// package private setters for setting/updating internal state
// used by FlowExecutionImplStateRestorer
@@ -172,14 +172,8 @@ class FlowSessionImpl implements FlowSession, Externalizable {
Assert.notNull(state, "The state is required");
Assert.isTrue(flow == state.getOwner(),
"The state does not belong to the flow associated with this flow session");
if (this.state != null && this.state.isViewState()) {
destroyViewScope();
}
this.state = state;
this.stateId = state.getId();
if (this.state.isViewState()) {
initViewScope();
}
}
/**
@@ -196,13 +190,17 @@ class FlowSessionImpl implements FlowSession, Externalizable {
return stateId;
}
// internal helpers
private void initViewScope() {
/**
* Initialize the view scope data structure.
*/
void initViewScope() {
scope.put(FLOW_VIEW_MAP_ATTRIBUTE, new LocalAttributeMap());
}
private void destroyViewScope() {
/**
* Destroy the view scope data structure.
*/
void destroyViewScope() {
scope.remove(FLOW_VIEW_MAP_ATTRIBUTE);
}

View File

@@ -208,7 +208,7 @@ public class ViewStateTests extends TestCase {
state.resume(context);
assertTrue(context.getFlowExecutionContext().isActive());
assertEquals("next", context.getCurrentState().getId());
assertFalse(context.getFlowScope().contains("foo"));
assertFalse(context.getViewScope().contains("foo"));
}
protected TransitionCriteria on(String event) {