Spring Web Flow - 页面上的多个表单 - 验证正确的表单

2024-02-11

我正在使用 Spring Web Flow 2.3,我有一个页面,上面有两个表单,根据提交的表单转换到不同的位置。为了实现这一目标,我为视图状态设置了一个复合模型对象,其中包含两种表单。我看到的问题是,如果转换 A 被触发,我只想验证表单 A,同样对于表单 B - 只想在 B 转换触发时验证 B。我不确定如何指示要验证的表单。查看为每个转换验证整个复合表单的状态:

<view-state model="compositeForm">
    <transition on="formAsubmit" to="formApage" validate="true"/>
    <transition on="formBsubmit" to="formBpage" validate="true"/>
</view-state>

有谁知道如何触发自定义验证器根据触发的转换进行不同的验证?

谢谢你的帮助。

Steve


我不知道每个的自定义验证器,但在您的验证方法中,我认为您可以使用RequestContextHolder.getRequestContext() https://docs.spring.io/spring-webflow/docs/current/api/org/springframework/webflow/execution/RequestContextHolder.html#getRequestContext-- to getCurrentTransition() https://docs.spring.io/spring-webflow/docs/current/api/org/springframework/webflow/execution/RequestContext.html#getCurrentTransition-- or getCurrentEvent() https://docs.spring.io/spring-webflow/docs/current/api/org/springframework/webflow/execution/RequestContext.html#getCurrentEvent--并手动比较getId() value.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Web Flow - 页面上的多个表单 - 验证正确的表单 的相关文章

随机推荐