私は、動的フォームテキストフィールドを含む単純なデータテーブルを持っています。各フィールドにはバッキングBeanで定義された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}ラベル}と "#{id}")。 – Travis