当 PrimeFaces 中不需要关联的 UIInput 时,如何在标签中显示 * 符号?
How to display * symbol in a label when the associated UIInput is not required in PrimeFaces?
我需要在 PrimeFaces 标签前面显示一个星号 (*) 符号,其样式与必需符号相同,而关联的 UIInput 的必需属性未设置为 true
。我知道在 PrimeFaces 6.0 中有一个名为 pfRequired
的属性可以满足我的要求,但我使用的是 PrimeFaces 6.1,我不想降级。 pfRequired
的用法是这样的:
<p:outputLabel value="Name: " for="username" />
<p:inputText id="username" pfRequired="#{true}" />
顺便说一句,在包括 Oracle ADF 在内的某些框架中,有一个名为 showRequired
的属性可以执行相同的操作。在不开发扩展 OutputLabelRenderer
的情况下如何在 PrimeFaces 6.1 中做到这一点?
幸运的是,正如@Kukeltje 在评论中提到的,已在 github 中创建并解决了一个问题以满足此要求:
OutputLabel: add possiblity to always display the required indicator
Currently we have an attribute called "indicateRequired".
True (default) means that the it's displayed when the component is required or @NotNull is present.
False means that it's never displayed.
The easiest way it the following now:
Auto (default) means that the it's displayed when the component is required or @NotNull is present.
true mean that it's always displayed
False means that it's never displayed.
问题的里程碑尚未确定。用法示例如下:
<p:outputLabel value="Name: " for="username" />
<p:inputText id="username" indicateRequired="true" />
我需要在 PrimeFaces 标签前面显示一个星号 (*) 符号,其样式与必需符号相同,而关联的 UIInput 的必需属性未设置为 true
。我知道在 PrimeFaces 6.0 中有一个名为 pfRequired
的属性可以满足我的要求,但我使用的是 PrimeFaces 6.1,我不想降级。 pfRequired
的用法是这样的:
<p:outputLabel value="Name: " for="username" />
<p:inputText id="username" pfRequired="#{true}" />
顺便说一句,在包括 Oracle ADF 在内的某些框架中,有一个名为 showRequired
的属性可以执行相同的操作。在不开发扩展 OutputLabelRenderer
的情况下如何在 PrimeFaces 6.1 中做到这一点?
幸运的是,正如@Kukeltje 在评论中提到的,已在 github 中创建并解决了一个问题以满足此要求:
OutputLabel: add possiblity to always display the required indicator
Currently we have an attribute called "indicateRequired". True (default) means that the it's displayed when the component is required or @NotNull is present. False means that it's never displayed.
The easiest way it the following now: Auto (default) means that the it's displayed when the component is required or @NotNull is present. true mean that it's always displayed False means that it's never displayed.
问题的里程碑尚未确定。用法示例如下:
<p:outputLabel value="Name: " for="username" />
<p:inputText id="username" indicateRequired="true" />