Is there a way to assign dynamic ids to h:inputHidden
components?
EDIT1
I am trying to assign the ids inside a ui:repeat
tag when iterating over a collection of elements.
Is there a way to assign dynamic ids to h:inputHidden
components?
EDIT1
I am trying to assign the ids inside a ui:repeat
tag when iterating over a collection of elements.
You can dynamically add any random number also (
id="#{}"
),butadd functionally related ids to hidden components, that will be helpful
for example if it is employee form ,you may add empid to it.
It is not possible to set the ID based on the iteration value of an
<ui:repeat>
. But you don't need it anyway. They will by default already get dynamic and unique IDs based on the iteration index.E.g.
will generate this HTML during view render time
If you want to manually control the ID, you'd need to use
<c:forEach>
instead, because<ui:repeat>
doesn't generate multiple JSF components, but lets its children (which is a single<h:inputHidden>
in the above example) generate HTML multiple times. The<c:forEach>
will generate multiple JSF components which then each generate HTML only once (so you effectively end up with multiple<h:inputHidden>
components in JSF component tree).E.g.
which will basically generate this JSF component tree during view build time
which in turn will generate this HTML during view render time
See also:
They get assigned a dynamic ID by default. You can also specify
id="#{..}
to customize it.