나는 동적 양식 텍스트 필드를 포함하는 간단한 데이터 테이블을 가지고 있습니다. 각 필드에는 ID가 백킹 빈에 정의되어 있으므로이 ID를 사용하여 각 h : inputText 필드를 식별하려고합니다.JSF 입력 ID가 h : dataTable 내에서 무시되었습니다.
<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>
페이지를 보려고하면 JSF가 오류 : The id attribute may not be empty
을 생성합니다. 내가 입력 ID 속성에 상수를 추가하는 경우
, 그것은 작동하지만 항목의 ID가 포함되어 있지 않습니다 생성 된 ID보고 :
<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>
:
<h:inputText id="#{item.id}abc" value="#{bean.values[item.id]}" />
이 다음과 같은 출력을 생성
반복 된 항목의 ID를 입력 ID 속성에 포함시킬 수 있습니까? ID가 누락 된 이유는 무엇입니까?
좋은 지적입니다. ID를 반드시 신경 쓰지 않아도됩니다. 텍스트 입력 필드 뒤에 레이블이 포함 된 복합 컨트롤을 생성하기 위해 ui : composition을 사용했기 때문에이 문제가 발생했습니다. 복합 컨트롤에 지정된 ID는 레이블과 입력 필드 모두에 사용되었습니다 (각각 "# {id} Label"및 "# {id}"). – Travis