如何设置验证消息的顺序? [英] How to set the order of validation messages?

查看:23
本文介绍了如何设置验证消息的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用错误消息"XPage(本机)控件向用户显示验证错误.有用.验证是通过根据需要设置字段并输入字段错误消息来完成的.没什么特别的.

We're using the "Error Messages" XPages (native) control to show the validation errors to user. It works. The validation is done by setting the field as required and entering the field error message. Nothing special.

现在的要求是按照它们在表单中出现的相同顺序设置错误消息.这可能吗?

Now the requirement is to set the error messages in to the same order as they appear in the form. Is this possible?

我想我可以创建一个自定义验证器 (Java) 并按特定顺序在那里进行所有表单验证(只是测试了 Validation 接口......但还没有真正使用 id).

I guess I could create a custom validator (Java) and doing all the form validations there in certain order (just tested the Validation interface... but not really used id, yet).

推荐答案

验证会按照它们在组件树中的顺序一一触发.根据您希望它们的显示方式,您可以移动组件,然后使用 css 设置它们的样式.或者,如果您真的只想在消息框中移动摘要语句的顺序,我会使用一些 JS 来移动它们,我相信它们只是呈现为 UL.只有一个验证器不会真正起作用,因为按照组件树的顺序,每个组件都会触发同一个验证器.

The Validations are fired one by one in order they are in the component tree. Depending on how you are wanting them to display you could move the components around and then style them with css. Or if you are really just wanting to move the order of the summary statements around in the Messages Box, I would just use some JS to move them around I believe they just render as a UL. Only having one Validator won't really work as the same validator will get fired for every component in the order of the component tree.

这篇关于如何设置验证消息的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆