문제

Does anybody know if it's possible to define dynamic transitions in a Spring Web Flow definition?

Example 1 - using a properties file:

<action-state id="createSubscription" >
    <evaluate expression="myvar" />
    <transition on="$[test.result.valid]" to="subscribeUser-successResponse" />
    <transition                               to="subscribeUser-exceptionResponse" />
</action-state>

Example 2 - using the value of the variable itself:

<action-state id="createSubscription" >
    <evaluate expression="myvar" />
    <transition to="$[myvar]" />
</action-state>

It's not mandatory, but could help to design more generic flows.

Thanks in advance to everyone.

도움이 되었습니까?

해결책

You can do definitely do for transition "to". Suppose flow xml has some action and view state as:

    <action-state id="createSubscription">
        <evaluate expression="myAction.prepareNextState(flowScope.formBean)"/>
        <transition to="${flowScope.formBean.displayNextState}">
    </action-state>

    <view-state id="someView" view="someView" model="formBean">
        ...
    </view-state>

and myAction class with prepareNextState method is as:

    public class MyAction implements Serializable{
        ....
        public void prepareNextState(FormBean formBean){
            //displayNextState is a String field in FormBean                
            formBean.setDisplayNextState("someView");
        }
        ....
    }

This way we can define generic transitions for transition "to".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top