绑定JSF中的列表列表

时间:2017-08-02 16:43:16

标签: jsf datatable nested-lists

这是我的班级 public class Sample { List<String> sampleKey; List<String> sampleValue; boolean editable; public Sample(List<String> sampleKey, List<String> sampleValue) { this.sampleKey = sampleKey; this.sampleValue = sampleValue; } public boolean isEditable() { return editable; } public void setEditable(boolean editable) { this.editable = editable; } public List<String> getsampleKey() { return sampleKey; } public void setsampleKey(List<String> sampleKey) { this.sampleKey = sampleKey; } public List<String> getsampleValue() { return sampleValue; } public void setsampleValuee(List<String> sampleValue) { this.sampleValue = sampleValue; } } public ArrayList<Sample> sampleList; Sample sam = null; sampleList = new ArrayList<Sample>(); List<Map.Entry<String, List<String>>> entryList = new ArrayList<>(records.entrySet()); for (int j = 0; j < maxSamples; j++) { ArrayList<String> sampleKey = new ArrayList<>(); ArrayList<String> sampleValue = new ArrayList<>(); for (int i = 7; i < records.size(); i++) { List<String> sample = entryList.get(i).getValue(); if (!sample.isEmpty()) { sampleKey.add(keyList.get(i)); if (!sample.get(j).isEmpty()) { sampleValue.add(sample.get(j)); } } } sam = new Sample(sampleKey, sampleValue); sampleList.add(sam); } ,它有2个列表作为键值对。一个样本由许多键值对组成。我希望在同一个bean类的视图中迭代这个示例列表。

<ui:repeat value="#{dataEntryFormController.sampleList}"
    var="key" varStatus="recordMetadata">
    <h:dataTable
        value="#{dataEntryFormController.sampleList[recordMetadata.index]}"
        var="o" binding="#{table}">
        <h:column>
            <h:inputText value="#{o.sampleKey[table.rowIndex]}" size="10" rendered="#{o.editable}" />
            <h:outputText value="#{o.sampleKey[table.rowIndex]}" rendered="#{not o.editable}" />
        </h:column>
        <h:column>
            <h:inputText value="#{o.sampleValue[table.rowIndex]}" size="20"rendered="#{o.editable}" />
            <h:outputText value="#{o.sampleValue[table.rowIndex]}" rendered="#{not o.editable}" />
        </h:column>
    </h:dataTable>
</ui:repeat>

现在这是我对同一个bean类的看法:

{{1}}

在我的JSF页面中,我想绑定列表列表以查看迭代多个样本,每个样本可能有许多键值对。使用上面的代码,我一次只能打印1个键值对。

我遇到了绑定问题。

0 个答案:

没有答案