【问题标题】:Different components in same column in datatable in JSF 2.0JSF 2.0中数据表中同一列中的不同组件
【发布时间】:2012-08-19 05:13:14
【问题描述】:

是否可以在使用 JSF 2.0 的数据表的单个列中包含不同类型的组件?

我的要求是基于label 列值,value 列将有相应的输入文本或选择列表。

目前我正在尝试通过支持 bean 来做到这一点。我在arraylist 中有label、value 和type of component(例如“选择列表”)。

当我在数据表中迭代此列表时,如何检查类型并根据结果创建输入或选择列表?

【问题讨论】:

    标签: java jsf


    【解决方案1】:

    在测试中使用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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-28
      • 2012-01-30
      • 2021-12-31
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      相关资源
      最近更新 更多