如何在匹配多个字段位置时显示多个验证错误,而不是一次显示默认错误?
假设您有一个带有十个 apex:inputFields 的 apex:form。所有这些字段都是必填字段,并且所有这些字段都有不允许为空字段的验证规则。
给定 10 个空字段的错误条件状态,Visualforce 的默认行为是,单击提交按钮后,它在字段位置附近一次仅显示 10 个错误之一。这是通过标准控制器完成的,因为它似乎为最后一个错误抛出异常(而不是聚合所有错误然后抛出异常)
我的问题是,如何在各自的字段附近显示多个 Visualforce 验证输入字段错误位置而不是一次一个标准位置? (这很烦人,因为您必须修复错误,然后分别单击提交按钮十次!)
Let's say you have an apex:form with ten apex:inputFields. All these fields are required and there are validation rules for all these fields that don't permit empty fields.
Given the error condition state of 10 empty fields, the default behavior of visualforce is that after you click on the submit button, it shows only one of the 10 errors at a time near the field location. This is done via the standard controller as it seems to throw an exception for the last error (as opposed to aggregating all the errors and then throwing the exception)
My question is then, how do you show multiple visualforce validation inputfield errors near their respective field locations instead of the standard one at a time? (which is annoying because you have to both fix the error and then click the submit button ten separate times!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这很烦人,您需要使用 jQuery 来获得一个简洁的解决方案。这里有一篇文章详细介绍了该过程: http://developinthecloud .wordpress.com/2010/03/02/visualforce-form-validation-enhanced/。
Yeah it's irritating, you'll need to use jQuery to get a neat solution. There's an article detailing the process here: http://developinthecloud.wordpress.com/2010/03/02/visualforce-form-validation-enhanced/.