如何使用仅显示一条验证错误消息 与 MyFaces 特立尼达?
对于注册表单,我有一些简单的内容,例如:
<tr:panelLabelAndMessage
label="Zip/City"
showRequired="true">
<tr:inputText
id="zip"
value="#{data['registration'].zipCode}"
contentStyle="width:36px"
simple="true"
required="true" />
<tr:inputText
id="city"
value="#{data['registration'].city}"
contentStyle="width:133px"
simple="true"
required="true" />
</tr:panelLabelAndMessage>
<tr:message for="zip" />
<tr:message for="city" />
当包含最后两行时,我收到两条有关验证错误的消息。 当省略最后一行时,会出现一个 javascript 警报,这不是我想要的。
有没有一种解决方案以某种方式仅显示一条验证失败消息?
多谢!
For a registration form I have something simple like:
<tr:panelLabelAndMessage
label="Zip/City"
showRequired="true">
<tr:inputText
id="zip"
value="#{data['registration'].zipCode}"
contentStyle="width:36px"
simple="true"
required="true" />
<tr:inputText
id="city"
value="#{data['registration'].city}"
contentStyle="width:133px"
simple="true"
required="true" />
</tr:panelLabelAndMessage>
<tr:message for="zip" />
<tr:message for="city" />
When including the last two lines, I get two messages on validation error. When ommiting last to lines, a javascript alert shows up, which is not what I want.
Is there a solution to show only one validation failed message somehow?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是,字段必须水平布局。 将邮政编码字段和城市不相邻地放在一行中是不行的。 至少对于我来说。
一位同事指示我在第一个 tr:message 中设置一个 faclets 变量,并将渲染的属性放在对此变量做出反应的第二个属性中。 还没有时间尝试,也没有找到设置变量的正确命令。 将尽快发布结果。
Problem is, the fields must layout horizontally. It's a no-go to put ZIP field and city not next to each other in one line. At least for me.
A co-worker has pointed me to set a faclets variable inside the first tr:message and to put a rendered attribute at the second one that reacts on this variable. Havn't got the time to try nor found the right command for setting a varable yet. Will post results as soon as possible.
我知道这并不理想,但如果您删除
panelLabelAndMessage
标记并仅使用inputText
标记上的 label 属性,应该会删除额外的错误消息。I know this won't be ideal, but if you remove the
panelLabelAndMessage
tag and just use the label attribute on theinputText
tag that should remove the extra error message.