2014-10-16 36 views
1

根據以下問題的答案接受後「時,選擇啓用的DataModel必須實現org.primefaces.model.SelectableDataModel」: FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled其執行SelectableDataModel或rowKey屬性添加到所需dataTable來避免這種異常。無論如何,我只是添加rowKey屬性,你可以看到和錯誤仍然發生,希望有人可以告訴我爲什麼。甚至增加rowKey值的dataTable

這是我的dataTable:

<p:dataTable var="item" rowKey="#{item.id}" style="margin-top:5px" emptyMessage="Nenhum registro encontrado" 
      value="#{controller.entidade.ecfs}" rows="10" selectionMode="single" 
      paginator="#{ecfController.showPaginator()}" paginatorPosition="bottom"> 

      <p:column headerText="Nº Série"> 
       <p:outputLabel value="#{item.numeroSerie}"/> 
      </p:column> 

      <p:column headerText="Modulo"> 
       <p:outputLabel value="#{item.modulo}"/> 
      </p:column> 

      <p:column headerText="Modelo"> 
       <p:outputLabel value="#{item.modelo}"/> 
      </p:column> 

      <p:column headerText="GT Inicial"> 
       <p:outputLabel value="#{item.gtInicial}"/> 
      </p:column> 

</p:dataTable> 

回答

0

我發現與rowKey屬性,你必須根據rowKey保證uniquiness,另一點是,如果你試圖插入一個新的對象與rowKey屬性作爲null它不會工作。