1min Tutorial - martinstrejc/boss-flow GitHub Wiki
1min. Tutorial A simple 1 minute tutorial, how to configure an easy 3 steps flow and invoke transitions. The first thing first is to prepare the configuration XML file. It is going to be parsed by JAXB, so you have to strictly respect XSD. 1min-example-flow.xml
<flowDescriptor xmlns="http://www.wicketstuff.cz/p/boss-flow/flowXmlModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1 1min-example-flow The 1 minute Tutorial example flow Now you have to initialize the flow processor. It can parse the XML file from an input stream. Also you can change some properties or add listeners etc. That is just going to be done once. It can be an application singleton, for example a Spring bean is a good solution for Spring based web applications. Initializing Flow // Create a new flow processor instance, that is going to hold FormData payload // as a flow data object IFlowProcessor processor = new DefaultFlowProcessor(); // Set the XML file with flow definitions, parse it and build flow processor.setFlowInputStream(new FileInputStream("1min-example-flow.xml")); processor.initializeProcessor(); // Now flow processor is ready to use Now se how to create the flow carter and shift between flow states. Running Flow // Initialize flow carter object with an payload of type FormData IFlowCarter carter = processor.initFlow(1, new FormData()); // Invoke a transition // for step 'S1initialState' you can use instead of 'goStep1to2' processor.invokeDefaultNextTransition(carter); // now the flow is in 'S2middleState' // Invoke a transition // There is no default next transition defined for the 'S2middleState' // so you have to invoke transition by its name processor.invokeTransition(carter, "goStep2to3"); // Obtain current state IFlowState currentState = carter.getCurrentState(); // Obtain current state name String currentStateName = currentState.getStateName(); // Obtain current view name String currentViewName = null; if(currentState instanceof IFlowViewState) { currentViewName = ((IFlowViewState)currentState).getViewName(); } // Obtain data object FormData formData = carter.getPayload(); That's all.