如何使用 仅显示一条验证错误消息 与 MyFaces 特立尼达?

发布于 2024-07-05 07:52:06 字数 841 浏览 8 评论 0 原文

对于注册表单,我有一些简单的内容,例如:

        <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 技术交流群。

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

发布评论

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

评论(2

吾家有女初长成 2024-07-12 07:52:06

问题是,字段必须水平布局。 将邮政编码字段和城市不相邻地放在一行中是不行的。 至少对于我来说。

一位同事指示我在第一个 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.

℉絮湮 2024-07-12 07:52:06

我知道这并不理想,但如果您删除 panelLabelAndMessage 标记并仅使用 inputText 标记上的 label 属性,应该会删除额外的错误消息。

I know this won't be ideal, but if you remove the panelLabelAndMessage tag and just use the label attribute on the inputText tag that should remove the extra error message.

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