且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用EL变量为标签动态分配ID

更新时间:2023-01-28 11:17:15

您不能在 id $中使用EL表达式c $ c>属性。

但是您不需要关心ui:repeat中ID的唯一性。 JSF为您做到了。只需给您的输入字段一个固定 ID,并在您的 p:message

But you don't need to care for the uniqueness of your ids in ui:repeat. JSF does it for you. Just give your input field a "fixed" id and reference it in your p:message:

<ui:repeat value="#{guestList}" var="guest">
    <p:inputText id="firstname" value="" label="Firstname" />
    <p:message for="firstname" />
</ui:repeat>