【发布时间】:2012-08-19 05:13:14
【问题描述】:
是否可以在使用 JSF 2.0 的数据表的单个列中包含不同类型的组件?
我的要求是基于label 列值,value 列将有相应的输入文本或选择列表。
目前我正在尝试通过支持 bean 来做到这一点。我在arraylist 中有label、value 和type of component(例如“选择列表”)。
当我在数据表中迭代此列表时,如何检查类型并根据结果创建输入或选择列表?
【问题讨论】:
是否可以在使用 JSF 2.0 的数据表的单个列中包含不同类型的组件?
我的要求是基于label 列值,value 列将有相应的输入文本或选择列表。
目前我正在尝试通过支持 bean 来做到这一点。我在arraylist 中有label、value 和type of component(例如“选择列表”)。
当我在数据表中迭代此列表时,如何检查类型并根据结果创建输入或选择列表?
【问题讨论】:
在测试中使用rendered 属性,该测试使用您用来区分输入和选择列表的任何内容。
例如
<h:dataTable value="#{yourBacking.yourList} var="item">
<h:column>
<h:inputText value="#{item.value}" rendered="#{item.type == 'input'}" />
<h:selectOneMenu value="#{item.value}" rendered="#{item.type == 'selectlist'}">
<f:selectItems value="#{item.values}" />
</h:selectOneMenu>
</h:column>
</h:dataTable>
【讨论】: