相关疑难解决方法(0)

使用JSF PrimeFaces时,在java.lang.String类型上不可读的属性

我正在尝试使用站点中的演示代码在数据表中实现延迟加载数据

PrimeFaces懒人加载

我收到了错误

javax.el.PropertyNotFoundException: /table.xhtml @14,49 value="#{car.year}": Property 'year' not readable on type java.lang.String
Run Code Online (Sandbox Code Playgroud)

这是我的table.xhtml代码

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">

    <h:form id="form">  

<p:dataTable var="car" value="#{tableBean.lazyModel}" paginator="true" rows="10"  
              id="carTable" lazy="true">  

    <p:column headerText="Year" sortBy="year" filterBy="#{car.year}">  
        <h:outputText value="#{car.year}" />  
    </p:column>  

    <p:column headerText="Color" sortBy="color" filterBy="#{car.color}">  
        <h:outputText value="#{car.color}" />  
    </p:column>  
</p:dataTable>      
Run Code Online (Sandbox Code Playgroud)

TableBean代码

@ManagedBean
public class TableBean {  

private LazyDataModel<Car> lazyModel;  

private List<Car> cars;

public TableBean() {
    System.out.println("Girish");
    cars = populateRandomCars(50);
    lazyModel = new LazyCarDataModel(cars);
    lazyModel.setRowCount(10);
}

public LazyDataModel<Car> getLazyModel() {
    return lazyModel;
}

public …
Run Code Online (Sandbox Code Playgroud)

java jsf primefaces jsf-2

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

标签 统计

java ×1

jsf ×1

jsf-2 ×1

primefaces ×1