JSF login id ignored inside h: dataTable

I have a simple data table containing dynamic form text fields. Each field has an identifier defined in the bean base, so I wanted to use this identifier 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 will generate an error: The id attribute may not be empty.

If I add a constant to the attribute of the input identifier, it works, but looking at the generated identifier, the element identifier does not turn on:

<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 an identifier from an iterated element in an input identifier attribute? Why is the identifier missing?

+3
1

?

. , . #{item} .

? ID. JSF HTML-. , JavaScript, .

+1

Source: https://habr.com/ru/post/1778988/


All Articles