Jsf 2 选择dataTable后出错
当我在dataTable中进行选择时,它给出了下面的错误Jsf 2 选择dataTable后出错,jsf-2,primefaces,Jsf 2,Primefaces,当我在dataTable中进行选择时,它给出了下面的错误 [javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or you need to define rowKey attribute]] 但在我的dataTable中,rowKey属性已经定义好了,我检查了它的值是否唯一。我出现这个错误的可能原因是什么
[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>
在此场景中将更新的数据库列
#{scenarioDataTable.scenarioApplicationColumnId}
#{scenarioDataTable.scenarioId}
#{scenarioDataTable.applicationColumnId}
#{scenarioDataTable.tableName}
#{scenarioDataTable.columnName}
#{scenarioDataTable.columnValidValue}
#{scenarioDataTable.dbAction}
看一看。rowKey
必须引用p:dataTable
中显示的属性(这是{myBean.scenarioApplicationColumnBOList}
对象之一的属性),例如
但不是
rowKey="scenarioDataTable.scenarioApplicationColumnId"
哦……愚蠢的错误。你知道我一整天都在发疯。无论如何,谢谢你指出错误
rowKey="scenarioDataTable.scenarioApplicationColumnId"