我声明了一个全局转换,我希望将“validate”属性的值设置为条件或设置为动作状态。 我想这样做:
<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>
此语法根本不起作用。有没有办法动态确定验证布尔值? 我正在研究的项目是使用2.3.1版本的Spring webflow。
感谢。
答案 0 :(得分:2)
我认为你不能将表达式用于boolean,因为它只需要文字真或假: http://www.w3.org/TR/xmlschema-2/#boolean
检查attirbute类型&#34;验证&#34;在spring webflow xsd中:
xsd:attribute name="validate" type="xsd:boolean"
相反,您可以做的是检测验证器本身的布尔值,并决定是否应该验证验证:
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();
...
}
}
}
答案 1 :(得分:0)
尝试使用evaluate
<evaluate expression="flowScope.validateGT1" result="flag" />
<global-transitions>
<transition on="gtransition1" to="gtransition1"
validate="flag" />
</global-transitions>