public class StepOne implements Step {
private StepFlow stepFlow;
public StepOne(StepFlow stepFlow) {
this.stepFlow = stepFlow;
}
@Override
public boolean shouldSkip() throws SystemException {
return false;
}
@Override
public void run() throws SystemException {
...
stepFlow.stepCompleted(this);
}
}
public class StepTwo implements Step {
private StepFlow stepFlow;
public StepTwo(StepFlow stepFlow) {
this.stepFlow = stepFlow;
}
@Override
public boolean shouldSkip() throws SystemException {
return false;
}
@Override
public void run() throws SystemException {
...
stepFlow.stepCompleted(this);
}
}
StepFlow stepFlow = new StepFlow();
stepFlow.addStep(new StepOne(stepFlow));
stepFlow.addStep(new StepTwo(stepFlow));
stepFlow.start();
Step 1: Shopping Cart
<viewConfig>
<viewType>ENTITY</viewType>
<propertiesToShow>orderItems</propertiesToShow>
...
<beanFlowNavigation direction="next">
<formDesign>
<entityType>Sales.SO</entityType>
<formId>1011-2</formId>
</formDesign>
<command visibleName="CheckOut" nameLocalized="false" />
</beanFlowNavigation>
</viewConfig>
The next step will be using the form design 1011-2. The next command display name is
CheckOut. Default is Continue.
Step 2: Shipping and Billing Addresses
<viewConfig>
<viewType>ENTITY</viewType>
<propertiesToShow>shippingMethod,shipTo,billTo</propertiesToShow>
...
<beanFlowNavigation direction="next">
<formDesign>
<entityType>Sales.SO</entityType>
<formId>1011-3</formId>
</formDesign>
</beanFlowNavigation>
</viewConfig>
The next step will be using the form design 1011-3.
Step 3: Payment Information
<viewConfig>
<viewType>ENTITY</viewType>
<propertiesToShow>payment</propertiesToShow>
...
<beanFlowNavigation direction="next">
<formDesign>
<entityType>Sales.SO</entityType>
<formId>1011-4</formId>
</formDesign>
</beanFlowNavigation>
</viewConfig>
The next step will be using the form design 1011-4.
Step 4: Confirmation
<viewConfig>
<viewType>ENTITY</viewType>
<propertiesToShow>store,customer,orderItems,totalBeforeTax,tax,total,shippingMethod,shipTo,billTo,payment</propertiesToShow>
<readOnly>true</readOnly>
<!-- calculate total price before showing confirm page -->
<param name="order.preCalcPrice" value="true"/>
<param name="order.preCalcPrice.ignoreError" value="false"/>
...
<beanFlowNavigation direction="next">
<formDesign>
<entityType>Sales.SO</entityType>
<!-- show completed order -->
<formId>1010</formId>
</formDesign>
<command exec="Pay" visibleName="CompleteOrder" nameLocalized="false" />
</beanFlowNavigation>
</viewConfig>
This step is a confirmation step showing all information entered in previous steps
and order total price is calculated before shown.
The next step will be using the form design 1010. The Next command display name is Complete Order. Before going to the next step, the action Pay will be executed, which will make payment. The payment may need to be redirected to a payment gateway for approval. After the payment is completed, the bean flow will navigate to its final step with form design 1010. The final step is not in a bean flow, so it can not go back to any previous step.
The exec attribute specifies a list of actions to take before navigation. The actions must be implemented in the EntityBackingBean as following. For example,
@Override
protected void execBeanFlowNavigationCommand(String command, Direction direction) throws SystemException {
if (direction.equals(WebFlowNavigation.Direction.NEXT)) {
if (command.equals("Pay")) {
// pay the order
}
}
}
See Bookmarkable URL - Redirect, and Redirect If Entity Not Found.