如何更新JSF 1.2中的组件以掩盖其渲染属性时不满意?

发布于 2025-02-10 03:49:44 字数 1105 浏览 2 评论 0原文

我正在使用JSF 1.2来构建表格。它是动态创建的,这意味着它并不总是相同的字段,也不是相同类型的字段(Chebox,Radio Buttom等)。需要其中一些字段,您知道这要归功于v.required属性。

他们要求我在加载页面后立即显示一个带有“必需值”的消息的信息,以便用户不必按Accept按钮即可知道是否需要哪些字段。问题在于,该站点已经实现了带有“不正确字符”和“必需值”的facesMessages的错误消息,因此当用户首次加载页面时,我的 *与我的消息一起出现,并且用户按下按下出现“ Accept”按钮,然后带有消息“需要”的facesmessages

这是我构建 *的方式:

<h:outputText for="#{idUtil.For(v)}" ajaxRendered="true" value="*" styleClass="required" rendered="#{v.requerido and facesMessages.getCurrentMessagesForControl(idUtil.For(v)).size()==0}"
                                                                                    title="Required value" />

这是我第一次加载页面时出现的方式: ,这就是我按“接受”按钮,我正在显示的 *和带有相同消息的面孔时出现的方式:

我如何何时隐藏我的 *出现面部?有什么办法可以按课堂读取组件?它不能按ID进行,因为当这些字段动态生成时,它们不能具有静态ID

I am using JSF 1.2 to build a form. It is created dynamically, which means that it will not always be the same fields, nor the same type of field (chebox, radio buttom, and others). Some of these fields are required, you know this thanks to the v.required property.

They ask me to display a * with a message that says "Required value" as soon as the page is loaded, so that the user does not have to press the accept button to know which fields are required or not. The problem is that the site has implemented error messages with FacesMessages that indicate with an "Incorrect characters" and also "Required value", so when the user loads the page for the first time my * appears with my message, and if the user presses the "Accept" button appears then the FacesMessages with the message "Value required"

This is how I build my *:

<h:outputText for="#{idUtil.For(v)}" ajaxRendered="true" value="*" styleClass="required" rendered="#{v.requerido and facesMessages.getCurrentMessagesForControl(idUtil.For(v)).size()==0}"
                                                                                    title="Required value" />

This is how it appears when I load the page for the first time:
enter image description hereand this is how it appears when I press the accept button, the * that I am showing and the FacesMessages with the same message: enter image description here

How can I hide my * when FacesMessages appears? Is there any way to reRendered components by class? It cannot be by id because when these fields are generated dynamically they cannot have a static id

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

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

发布评论

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

评论(1

月朦胧 2025-02-17 03:49:44

您可以尝试使用选择器来选择所需类所需的所有输出文本,以便它们重估渲染条件,并通过对该变量的消息进行消息,列表的长度将与0不同,因此 *将被隐藏。

<p:commandButton update="@(.required)" />

You can try to use a selector to select all the outputtext belonging to the class required so that they revalue the rendered condition and by having a message for that variable the length of the list would be different from 0, therefore the * will be hidden.

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