This commit is contained in:
@@ -111,6 +111,10 @@ public class ViewState extends TransitionableState {
|
||||
return (ViewVariable[]) variables.values().toArray(new ViewVariable[variables.size()]);
|
||||
}
|
||||
|
||||
public boolean getRedirect() {
|
||||
return redirect.booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this view state should send a flow execution redirect when entered.
|
||||
* @param redirect the redirect flag
|
||||
@@ -119,6 +123,10 @@ public class ViewState extends TransitionableState {
|
||||
this.redirect = Boolean.valueOf(redirect);
|
||||
}
|
||||
|
||||
public boolean getPopup() {
|
||||
return popup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this view state should render as a popup.
|
||||
* @param popup the popup flag
|
||||
@@ -127,6 +135,10 @@ public class ViewState extends TransitionableState {
|
||||
this.popup = popup;
|
||||
}
|
||||
|
||||
public ViewFactory getViewFactory() {
|
||||
return viewFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of actions executable by this view state on entry and on refresh. The returned list is mutable.
|
||||
* @return the state action list
|
||||
@@ -232,4 +244,5 @@ public class ViewState extends TransitionableState {
|
||||
super.appendToString(creator);
|
||||
creator.append("viewFactory", viewFactory).append("variables", variables);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,10 @@ public class ActionExecutingViewFactory implements ViewFactory {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public View getView(RequestContext context) {
|
||||
return new ActionExecutingView(action, context);
|
||||
}
|
||||
@@ -71,5 +75,4 @@ public class ActionExecutingViewFactory implements ViewFactory {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,14 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.factory.support.StaticListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.webflow.action.ExternalRedirectAction;
|
||||
import org.springframework.webflow.action.FlowDefinitionRedirectAction;
|
||||
import org.springframework.webflow.engine.Flow;
|
||||
import org.springframework.webflow.engine.ViewState;
|
||||
import org.springframework.webflow.engine.builder.FlowAssembler;
|
||||
import org.springframework.webflow.engine.builder.FlowBuilderException;
|
||||
import org.springframework.webflow.engine.builder.support.ActionExecutingViewFactory;
|
||||
import org.springframework.webflow.execution.ViewFactory;
|
||||
import org.springframework.webflow.security.SecurityRule;
|
||||
import org.springframework.webflow.test.MockFlowBuilderContext;
|
||||
|
||||
@@ -132,4 +136,43 @@ public class XmlFlowBuilderTests extends TestCase {
|
||||
Flow flow = assembler.assembleFlow();
|
||||
assertNotNull(((ViewState) flow.getStateInstance("view")).getVariable("foo"));
|
||||
}
|
||||
|
||||
public void testViewStateRedirect() {
|
||||
ClassPathResource resource = new ClassPathResource("flow-viewstate-redirect.xml", getClass());
|
||||
builder = new XmlFlowBuilder(resource);
|
||||
FlowAssembler assembler = new FlowAssembler(builder, new MockFlowBuilderContext("flow"));
|
||||
Flow flow = assembler.assembleFlow();
|
||||
assertTrue(((ViewState) flow.getStateInstance("view")).getRedirect());
|
||||
}
|
||||
|
||||
public void testViewStatePopup() {
|
||||
ClassPathResource resource = new ClassPathResource("flow-viewstate-popup.xml", getClass());
|
||||
builder = new XmlFlowBuilder(resource);
|
||||
FlowAssembler assembler = new FlowAssembler(builder, new MockFlowBuilderContext("flow"));
|
||||
Flow flow = assembler.assembleFlow();
|
||||
assertTrue(((ViewState) flow.getStateInstance("view")).getPopup());
|
||||
}
|
||||
|
||||
public void testViewStateFlowRedirect() {
|
||||
ClassPathResource resource = new ClassPathResource("flow-viewstate-flowredirect.xml", getClass());
|
||||
builder = new XmlFlowBuilder(resource);
|
||||
FlowAssembler assembler = new FlowAssembler(builder, new MockFlowBuilderContext("flow"));
|
||||
Flow flow = assembler.assembleFlow();
|
||||
ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
|
||||
assertTrue(vf instanceof ActionExecutingViewFactory);
|
||||
ActionExecutingViewFactory avf = (ActionExecutingViewFactory) vf;
|
||||
assertTrue(avf.getAction() instanceof FlowDefinitionRedirectAction);
|
||||
}
|
||||
|
||||
public void testViewStateExternalRedirect() {
|
||||
ClassPathResource resource = new ClassPathResource("flow-viewstate-externalredirect.xml", getClass());
|
||||
builder = new XmlFlowBuilder(resource);
|
||||
FlowAssembler assembler = new FlowAssembler(builder, new MockFlowBuilderContext("flow"));
|
||||
Flow flow = assembler.assembleFlow();
|
||||
ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
|
||||
assertTrue(vf instanceof ActionExecutingViewFactory);
|
||||
ActionExecutingViewFactory avf = (ActionExecutingViewFactory) vf;
|
||||
assertTrue(avf.getAction() instanceof ExternalRedirectAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user