相关疑难解决方法(0)

FacesException:启用选择时,DataModel必须实现org.primefaces.model.SelectableDataModel

我正在尝试学习PF所以我开始首先显示datatable并导航到rowClick传递参数的下一页,但是遇到了以下错误.我发现了这个问题的类似问题,但还没有运气.我希望有人会帮助我.

我收到以下错误:

DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.

Caused by:
javax.faces.FacesException - DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.
Run Code Online (Sandbox Code Playgroud)

我的页面:

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

<h:head>
<title>Primefaces 3.1</title>

</h:head>
<h:body>
    <h:form id="form">          
            <p:dataTable value="#{tableBean.cars}" var="var" rowkey="#{var.model}" 
            selection="#{tableBean.car}" selectionMode="single">
            <p:column>  <f:facet name="header">
                                <h:outputText styleClass="outputText" value="Model"></h:outputText>
                            </f:facet>
                            <h:outputText styleClass="outputText"
                                value="#{var.model}"></h:outputText>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText styleClass="outputText" value="Color"></h:outputText>
                            </f:facet>
                            <h:outputText styleClass="outputText"
                                value="#{var.randomColor}"></h:outputText>
                        </p:column></p:dataTable>                               
        </h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的bean类:

@ManagedBean …
Run Code Online (Sandbox Code Playgroud)

primefaces jsf-2

6
推荐指数
1
解决办法
5万
查看次数

标签 统计

jsf-2 ×1

primefaces ×1