在 jsf 提交时,selectOneMenu 验证器仅在 required=“true”时运行已设置。为什么?
我发现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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这确实是按照规范进行的。顺便说一句,这也适用于所有其他输入元素。
你不能。如果您需要最终用户选择某个项目,只需指定
required="true"
属性即可。默认情况下它是可选的,因为在某些情况下您可能不需要最终用户选择某个项目。That's indeed by specification. This applies to all other input elements as well, by the way.
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.