I have a simple data table which contains dynamic form text fields. Each field has an ID defined in the backing bean, so I wanted to use that ID to identify each of the h:inputText fields.
<h:dataTable id="fieldTable" value="#{bean.indexFields}" var="item">
<h:column id="column">
<h:inputText id="#{item.id}" value="#{bean.values[item.id]}" />
</h:column>
</h:dataTable>
When I try to view the page, JSF generates an error: The id attribute may not be empty.
If I add a constant to the input ID attribute, it works, but looking at the generated ID the item's ID is not included:
<h:inputText id="#{item.id}abc" value="#{bean.values[item.id]}" />
This generates the following output:
<table id="form:fieldTable">
<tbody>
<tr>
<td><input id="form:fieldTable:0:abc" type="text" name="form:fieldTable:0:abc" title="" /></td>
</tr>
<tr>
<td><input id="form:fieldTable:1:abc" type="text" name="form:fieldTable:1:abc" title="" /></td>
</tr>
<tr>
<td><input id="form:fieldTable:2:abc" type="text" name="form:fieldTable:2:abc" title="" /></td>
</tr>
</tbody>
</table>
Is there a way to include the id from the iterated item in the input id attribute? Why is the ID omitted?