【问题标题】:Radio Button issue while Iterating over a collection in Struts 2迭代 Struts 2 中的集合时出现单选按钮问题
【发布时间】:2017-07-22 11:18:05
【问题描述】:

我有一个列表名称 companyList 迭代以显示表中的用户列表。每一行都有公司名称和一个单选按钮来选择公司 id 。 这里的问题是我如何为具有相应公司 ID 的行绑定单选按钮显示用户只能从表中选择一个公司 ID,因为我确实有列表值与单选绑定。

=Company Name=|=Company ID====

ABC           | radio with company ID 1
XYZ           | radio with company ID 2
<display:table uid="companyConfig" name="dataExchangeCompanyList" htmlId="companyListTable" requestURI="ncrDatapackageExport!ajax" ajax="true">
    <!-- Company Name -->
    <display:column titleKey="tdp.export.company.name" class="company-column textLeft" sortable="true" sortProperty="company">
        <s:property value="#attr.companyConfig.company"/>
    </display:column>
    <!-- Check Box  -->

    <display:column titleKey="tdp.export.select" class="textCentre" media="html">
        <s:radio name="selectedCompanies" value="%{#attr.companyConfig.id}" />
    </display:column>

</display:table>

这里我使用显示表来遍历列表

【问题讨论】:

    标签: struts2 struts jsp-tags displaytag


    【解决方案1】:

    按名称绑定控件。您应该在提交表单时指定将存储所选值的属性的索引。

    <display:column titleKey="tdp.export.select" class="textCentre" media="html">
      <s:radio name="selectedCompanies[%{#attr.companyConfig_rowNum - 1}]" value="%{#attr.companyConfig.id}" />
    </display:column>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-02
      • 2020-05-26
      • 1970-01-01
      • 2017-11-17
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多