我使用 Spring Webflow 2,我需要在我的验证器中检测触发的转换事件 ID。
在我的 flow.xml
<view-state id="stepFinal" view="/registration/consultant/registr-step-final" model="consultant">
<transition on="addSkill" to="stepFinal" validate="true" bind="true"/>
<transition on="deleteSkill" to="stepFinal" validate="true" bind="true"/>
<transition on="back" to="stepOne" validate="true" bind="true"/>
<transition on="preview" to="stepPreview" validate="true" bind="true"/>
</view-state>
我的“顾问”模型验证器
@Component
public class ConsultantValidator implements Validator {
public boolean supports(Class clazz) { return clazz.equals(ConsultantRegistrationModel.class); }
public void validate(Object object, Errors errors) {
ConsultantRegistrationModel consultantModel = (ConsultantRegistrationModel) object;
// My validations here
// Here I want to detect the event id which was fired.
// For example (see in my flow.xm)
// I have:
// transition on="addSkill"
// transition on="deleteSkill"
// transition on="back"
// transition on="preview"
// I want to detect here if is it "addSkill" or "deleteSkill" or "back" or "preview"?
// Any solutions?
}
我希望我在代码片段中的评论中非常清楚。任何帮助将非常感激。
还
RequestContextHolder.getRequestContext().getCurrentEvent()
没有帮助,因为它返回 null
至于
RequestContextHolder.getRequestContext().getCurrentView().getUserEventState()
它实际上包含事件 id,但它的 getter 是受保护的,所以我无法获得它。