DataList - Lazy

DataList has built-in support to deal with huge datasets. In order to enable lazy loading, a LazyDataModel needs to be implemented to query the datasource when pagination happens. This example uses an in-memory list to mimic a real datasource like a database.

In a real application, loading should be executed with the query built using the information passed to the load method.

  • Id: 58c29341
    Year: 2002
    Color: Black
  • Id: 88f44c34
    Year: 1979
    Color: Blue
  • Id: 4d0e3be7
    Year: 1960
    Color: Yellow
  • Id: 633b9388
    Year: 1979
    Color: Yellow
  • Id: d4d93de8
    Year: 1961
    Color: Maroon
Car Info
<style type="text/css">
    .logo {

    .detail {
        width: 200px;
        padding-left: 25px;

    .command {
        padding-left: 25px;

    ul.ui-datalist-data {
        padding-inline-start: 0px;

<h:form id="form">
    <p:dataList value="#{dtLazyView.lazyModel}" var="car" lazy="true" type="unordered" itemType="none" style="width: 450px"
                paginator="true" rows="5" rowsPerPageTemplate="5,10,20" pageLinks="5"
                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
        <h:panelGrid columns="3" columnClasses="logo,detail">
            <p:graphicImage name="demo/images/car/#{car.brand}-big.gif" />

                <h:panelGrid columns="2" cellpadding="5">
                    <h:outputText value="Id:" />
                    <h:outputText value="#{}" style="font-weight: bold"/>

                    <h:outputText value="Year:" />
                    <h:outputText value="#{car.year}" style="font-weight: bold"/>

                    <h:outputText value="Color:" />
                    <h:outputText value="#{car.color}" style="font-weight: bold"/>

            <p:commandLink update=":form:carDetail" oncomplete="PF('carDialog').show()" title="View Detail">
                <h:outputText styleClass="ui-icon pi pi-search" style="margin:0 auto;" />
                <f:setPropertyActionListener value="#{car}" target="#{dtLazyView.selectedCar}" />

    <p:dialog header="Car Info" widgetVar="carDialog" modal="true" showEffect="blind" hideEffect="explode" resizable="false">
        <p:outputPanel id="carDetail" style="text-align:center;">
            <p:panelGrid  columns="2" rendered="#{not empty dtLazyView.selectedCar}" columnClasses="label,value">
                <f:facet name="header">
                    <p:graphicImage name="demo/images/car/#{dtLazyView.selectedCar.brand}-big.gif"/>

                <h:outputText value="Id:" />
                <h:outputText value="#{}" />

                <h:outputText value="Year" />
                <h:outputText value="#{dtLazyView.selectedCar.year}" />

                <h:outputText value="Color:" />
                <h:outputText value="#{dtLazyView.selectedCar.color}" style="color:#{dtLazyView.selectedCar.color}"/>

                <h:outputText value="Price" />
                <h:outputText value="$#{dtLazyView.selectedCar.price}" />


Built-in component themes created by the PrimeFaces Theme Designer.

nova-light Nova-Light
nova-dark Nova-Dark
nova-colored Nova-Colored
luna-blue Luna-Blue
luna-amber Luna-Amber
luna-green Luna-Green
luna-pink Luna-Pink
omega Omega


Create awesome applications in no time using the premium templates and impress your users.