Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeFaces lazydatamodel load method not called

I happen not to understand why my load method is not called in a lazydatamodel of my primefaces table. My xhtml page goes like this

<h:form id="myForm">
    <p:dataTable value="#{myBean.configDataModel}"
                            id="configTable" var="config" paginator="true" rows="10"
                            selectionMode="single"
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                            rowsPerPageTemplate="5,10,20">
    .
    .
</h:form>

My Bean code goes like this and put up system.out.println statements but I notice it isn't called.

public class MyBean{
    // private List<MyBean> configList;
    private LazyDataModel<MyBean> configDataModel;

    @SuppressWarnings("serial")
    public LazyDataModel<MyBean> getConfigDataModel() {
        if (configDataModel == null) {
            configDataModel = new LazyDataModel<MyBean>() {

                @Override
                public List<MyBean> load(int arg0, int arg1, String arg2,
                        SortOrder arg3, Map<String, String> arg4) {
                    System.out.println("Here!!!!!");
                    return null;
                }
            };

        }
        return configDataModel;
    }
    public void setConfigDataModel(LazyDataModel<MyBean> configDataModel) {
        this.configDataModel = configDataModel;
    }
}

What could be the cause?

like image 250
Mark Estrada Avatar asked Nov 06 '12 02:11

Mark Estrada


1 Answers

Since PrimeFaces 3.3, you'd need to explicitly set the lazy attribute of the repeating component to true in order to enable the support for LazyDataModel.

<p:dataTable ... lazy="true">

See also:

  • PrimeFaces showcase - DataTable - Lazy Loading
like image 194
BalusC Avatar answered Nov 07 '22 21:11

BalusC