Spring Web Flow has something called subflow which allows one webflow to invoke another webflow (possibly defined in a different module). When designed properly, webflow allows collaboration of disparate modules.
<!-- id: handle for this subflow. subflow: registered webflow name. by convention, spring names webflow by using the XML definition filename minus .xml. --> <subflow-state id="questionGroupStep" subflow="questionnaire"> <transition on="viewClientDetails" to="selectCustomerStep"></transition> </subflow-state> |
<view-state id="customerSearchStep" view="createSavingsAccountCustomerSearch" model="savingsAccountFormBean"> <transition on="searchTermEntered" to="questionGroupStep" validate="true"></transition> </view-state> |
@Override protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) { ... // setup questionnaire subflow Flow questionnaire = new Flow("questionnaire"); State start = new State(questionnaire, "selectQuestionnaire") { @Override protected void doEnter(RequestControlContext context) throws FlowExecutionException { // empty } }; questionnaire.setStartState(start); builderContext.registerSubflow(questionnaire); } |
@Test public void testCustomerSearchStep_SearchTermEntered() { setCurrentState("customerSearchStep"); MockExternalContext context = new MockExternalContext(); context.setEventId("searchTermEntered"); resumeFlow(context); assertCurrentStateEquals("selectQuestionnaire"); } |