我需要知道如何创建自定义验证规则以应用于Activiti表单中的特定字段以及如何将所有文件一起部署到其引擎。
谢谢
I need to know how to create a custom validation rule to be applied to a specific field in an Activiti form and how to deploy all the files together to its engine.
Thanks
最满意答案
对于可重复使用的字段级验证(例如:电话号码,邮政编码等),我认为最好的方法是在引擎配置中注册自定义FormType(请参阅Activiti用户指南中的9.1项)。 自定义FormType实现是通过扩展AbstractFormType并实现一些方法来创建的,这些方法将字符串转换为/从内部转换为您想要在内部使用的任何表示形式。
表单级别验证(即,作为整体应用于表单的验证)我通常使用附加到侦听EVENTNAME_COMPLETE事件的任务的TaskListener 。 在此侦听器中,您执行验证逻辑并在出现错误时抛出异常。
至于“将所有内容组合在一起”:对于最简单的情况,您只需使用额外的验证类创建一个jar并将其放在类路径中。 如果您希望在您的流程中部署此代码,则没有直接的答案。 这是可能的,但我认为这应该是另一个问题的主题。
For reusable field level validations (e.g: phone number, zip code, etc), I think the best approach is to register a custom FormType in the engine´s configuration (check item 9.1 on Activiti´s user guide). Custom FormType implementations are created by extending AbstractFormType and implementing a few methods that converts to/from a String into whatever representation you want to use internally.
Form level validation (i.e., validations that are applied to the form as a whole) I usually use a TaskListener attached to the task that listens to the EVENTNAME_COMPLETE event. In this listener you do your validation logic and throw an exception in case something is wrong.
As for "deploying everything together": For the simplest case, you just create a jar with the extra validation classes and put it in your classpath. If you want this code to be deployed with your process then there is no straightforward answer. It is possible, but I think this should be the topic for another question.
更多推荐
Activiti,验证,form,规则,电脑培训,计算机培训,IT培训"/> <meta name="descripti
发布评论