Вот рабочий пример
myDataTableLazy.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:icecore="http://www.icefaces.org/icefaces/core">
<h:head>
<title>DataTable</title>
</h:head>
<h:body>
<h:form>
<ace:dataTable id="carTable"
value="#{myDataTableLazy.lazyModel}"
var="car"
rows="5"
paginator="true"
lazy="true" >
<ace:column id="exp" rendered="false">
<ace:expansionToggler />
</ace:column>
<ace:column headerText="Id">
<ice:outputText value="#{car.id}" />
</ace:column>
<ace:column headerText="Name">
<ice:outputText value="#{car.name}" />
</ace:column>
</ace:dataTable>
<h:commandButton id="invio" value="Invio" actionListener="#{myDataTableLazy.cicla}" >
</h:commandButton>
</h:form>
MyDataTableLazy
package my;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
import org.icefaces.ace.model.table.LazyDataModel;
import org.icefaces.samples.showcase.example.ace.dataTable.DataTableLazyLoading;
import org.icefaces.samples.showcase.metadata.context.ComponentExampleImpl;
@ManagedBean(name="myDataTableLazy")
@SessionScoped
public class MyDataTableLazy implements Serializable {
private LazyDataModel<Car> lazyModel;
@PostConstruct
public void init() {
lazyModel = new LazyCarDataModel();
}
public LazyDataModel<Car> getLazyModel() {
return lazyModel;
}
public void setLazyModel(LazyDataModel<Car> lazyModel) {
this.lazyModel = lazyModel;
}
public void cicla(ActionEvent e) {
List<Car> lista = (List<Car>) lazyModel.getWrappedData();
for (Car car : lista) {
System.out.println( car.getName() );
}
}
}
LazyCarDataModel
package my;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.icefaces.ace.model.table.LazyDataModel;
import org.icefaces.ace.model.table.SortCriteria;
public class LazyCarDataModel extends LazyDataModel<Car> {
List<Car> carList;
public LazyCarDataModel(){
carList = new ArrayList<Car>();
carList.add(new Car(1, "FiatLazy"));
carList.add(new Car(2, "FerrariLazy"));
carList.add(new Car(3, "PorscheLazy"));
carList.add(new Car(4, "MaseratiLazy"));
carList.add(new Car(5, "MercedesLazy"));
carList.add(new Car(6, "BMWLazy"));
carList.add(new Car(7, "ToyotaLazy"));
carList.add(new Car(8, "FordLazy"));
carList.add(new Car(9, "Alfa RomeoLazy"));
carList.add(new Car(10, "SuzukiLazy"));
carList.add(new Car(11, "RenaultLazy"));
setRowCount(carList.size());
}
@Override
public List<Car> load(int first, int pageSize, SortCriteria[] arg2, Map<String, String> arg3) {
ArrayList list = new ArrayList<Car>();
int initial = first;
for (int i = initial; i < initial + pageSize && i < carList.size(); i++) {
list.add(carList.get(i));
}
return list;
}
}