0
votes

I have a global-transition declared and I would like the value of the "validate" attribute to be conditionned or set in an action-state. Here is how I would like to do it :

<decision-state id="decision_view">
    <if test="condition == true" then="actionState1" />
</decision-state>

<action-state id="actionState1">
    <evaluate result="flowScope.validateGT1" expression="true"/>
</action-state>

<global-transitions>
    <transition on="gtransition1" to="gtransition1" 
    validate="flowScope.validateGT1" /> // Does not work, syntax error
</global-transitions>

This syntax does not work at all. Is there a way to determine the validate boolean dynamically ? The project I am working on is using a 2.3.1 version of Spring webflow.

Thanks.

2
Have you tried validate="${flowScope.validateGT1}"Nikhil Talreja
My IDE shows the following error : Wrong attribute value.maxsoulard
And at the execution : '${flowScope.validateGT1}' n'est pas une valeur valide pour 'boolean'. (=> is not a valid boolean value).maxsoulard

2 Answers

2
votes

I think you cannot use the expression for boolean as it expects only literals true or false: http://www.w3.org/TR/xmlschema-2/#boolean

Check the attirbute type for "validate" in spring webflow xsd:

    xsd:attribute name="validate" type="xsd:boolean"

Instead what you can do is retrieve the boolean value in validator itself and decide if validation should be done or not as:

    public class YourValidator {
        public void validateStateId(YourModel model, ValidationContext context) {
            RequestContext requestContext = RequestContextHolder.getRequestContext();
            boolean shouldValidate = (Boolean)requestContext.getFlowScope.get("validateGT1");
            if(shouldValidate){
                MessageContext messages = context.getMessageContext();
                ...
            }
        }
    }
0
votes

Try to use evaluate

<evaluate expression="flowScope.validateGT1" result="flag" />

<global-transitions>
    <transition on="gtransition1" to="gtransition1" 
    validate="flag" />
</global-transitions>