在 jsf 提交时,selectOneMenu 验证器仅在 required=“true”时运行已设置。为什么?

发布于 2024-12-27 08:12:38 字数 102 浏览 2 评论 0原文

我发现jsf验证器绑定到selectOneMenu,只有当selectOneMenu有required =“true”时才会在提交时调用。我如何解决这个问题以在没有该属性的情况下调用验证器?

I discovered that jsf validator binded to selectOneMenu, on submit is called only when selectOneMenu have required="true". How can i resolve this to call validator without that attribute?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

始于初秋 2025-01-03 08:12:38

我发现jsf验证器绑定到selectOneMenu,只有当selectOneMenu具有required =“true”时才会在提交时调用。

这确实是按照规范进行的。顺便说一句,这也适用于所有其他输入元素。


如何解决此问题以在没有该属性的情况下调用验证器?

你不能。如果您需要最终用户选择某个项目,只需指定 required="true" 属性即可。默认情况下它是可选的,因为在某些情况下您可能不需要最终用户选择某个项目。

I discovered that jsf validator binded to selectOneMenu, on submit is called only when selectOneMenu have required="true".

That's indeed by specification. This applies to all other input elements as well, by the way.


How can i resolve this to call validator without that attribute?

You cannot. Just specify the required="true" attribute if you require the enduser to select an item. It's by default optional because there may be circumstances where you don't require the enduser to select an item.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文