0

当我在 dataTable 中进行选择时,会出现以下错误

[javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or you need to define rowKey attribute]]

但是在我的 dataTable rowKey 属性中已经定义并且我检查了它的值是唯一的。我收到此错误的可能原因是什么

数据表代码如下

<p:dataTable id="scenarioDataTableId" var="scenarioDataTable" value="#{myBean.scenarioApplicationColumnBOList}" tableStyle="width:90%" rowKey="scenarioDataTable.scenarioApplicationColumnId" selection="#{myBean.selectedScenarioApplicationColumnRow}" >
    <f:facet name="header">Database Columns That will be updated in this Scenario</f:facet>

    <p:ajax event="rowSelectRadio" listener="#{myBean.editSelectedScenarioApplicationColumnAction}"></p:ajax>
    <p:column selectionMode="single" style="width:10%" /> 

    <p:column id="Id" headerText="Id" >
                            #{scenarioDataTable.scenarioApplicationColumnId}
    </p:column>

    <p:column id="scenarioId" headerText="Scenario Id" >
                            #{scenarioDataTable.scenarioId}
    </p:column>

    <p:column id="appId" headerText="Application Column Id" >
                            #{scenarioDataTable.applicationColumnId}
    </p:column>

    <p:column id="tableNameId" headerText="Table Name" >
                            #{scenarioDataTable.tableName}
    </p:column>

    <p:column id="columnNameId" headerText="Column Name" >
                            #{scenarioDataTable.columnName}
    </p:column>

    <p:column id="columnValidValueId" headerText="Column Valid Value" >
                            #{scenarioDataTable.columnValidValue}
    </p:column>

    <p:column id="dbActionId" headerText="DB Action" >
                            #{scenarioDataTable.dbAction}
    </p:column>

    <f:facet name="footer">
        <p:commandButton value="Add New Row" action="#{myBean.openDialogScenarioUpdateColumn}" oncomplete="dialogScenarioUpdateColumn.show()" rendered="#{myBean.scenarioInputFieldRendered}"></p:commandButton>    
        <p:spacer width="20" ></p:spacer>
        <p:commandButton id="editButton" value="Edit" action="#{myBean.editSelectedScenarioApplicationColumnAction}" update=":formSelectCriteria:ScenarioMainPanel" ></p:commandButton>
        <p:spacer width="20" ></p:spacer>
        <p:commandButton id="deleteButton" value="Delete"></p:commandButton>
    </f:facet>

</p:dataTable>
4

1 回答 1

0

看看Primefaces 展示柜。ArowKey必须引用您显示的属性p:dataTable(这是您的一个#{myBean.scenarioApplicationColumnBOList}对象的属性),例如

rowKey="#{scenarioDataTable.scenarioApplicationColumnId}"

但不是

rowKey="scenarioDataTable.scenarioApplicationColumnId"
于 2013-08-06T06:44:24.060 回答