2017-03-02 77 views
0

我有一个列表名称companyList迭代以显示表中的用户列表。每行都有公司名称和一个单选按钮来选择公司ID。 这里问题是我如何绑定一行的单选按钮与各自的公司ID显示,用户可以从表中选择只有一个公司ID,因为我确实有与无线电绑定的列表值。在Struts 2中迭代集合时的单选按钮问题

=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> 

这里我使用的显示表列表

回答

0

绑定迭代的名字控制。您应该为提交表单时所选值存储的属性指定索引。

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