A Stupid Mistake, I'm Sure

UI Components for JSF
Post Reply
grenadadoc
Posts: 34
Joined: 23 Mar 2010, 15:58

22 Aug 2010, 21:11

I have tried to use lazy loading on a datatable using 2.2 SnapShot from 20 Aug 2010.
The table appears, the paginator appears and displays the correct number of 'pages available'. The page w/ move from page to page. Only problem -- no data in the table. The lazyDataModel is being called.

What is the simple mistake that I'm overlooking?

Thanks in advance.

JSF2 code...

Code: Select all

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListPatientsTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <br />
                <h:commandLink value="#{bundle.ListPatientsIndexLink}" action="/index" immediate="true" />
                <br />
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:panelGroup rendered="true">
                    <p:dataTable id="ptTable" var="pt" value="#{patientsMB.lazyModelPts}" paginator="true"
                                 dynamic="true" lazy="true" rows="25" rowsPerPageTemplate="25, 50, 100, 500"
                                 paginatorTemplate="{FirstPageLink}{PreviousPageLink}{PageLinks}{NextPageLink}{LastPageLink} {RowsPerPageDropdown}"
                                 selectionMode="single" selection="#{patientsMB.selected}">
                        <p:column sortBy="#{pt.patientFileID}" filterBy="#{pt.patientFileID}"
                                  headerText="PatientFileID" resizable="true">
                            <h:outputText value="#{pt.patientFileID}"/>
                        </p:column>
                        <p:column headerText="PatientID" resizable="true">
                            <h:outputText value="#{pt.patientID}"/>
                        </p:column>

                    </p:dataTable>
                </h:panelGroup>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
Managed bean code ...

Code: Select all

@ManagedBean (name="patientsMB")
@SessionScoped
public class PatientsMB {

    private Patients selected, item;
    private List<Patients> itemList;
    @EJB
    private PatientsFacade ptFacade;
    private LazyDataModel<Patients> lazyModelPts;
    private int selectedItemIndex;

    /** Creates a new instance of PatientsMB */
    public PatientsMB() {
        System.out.println("PatientsMB Constructor called");
    }

    @PostConstruct()
    public void loadDefaults() {
        lazyModelPts = new LazyDataModel<Patients>(ptFacade.count()) {

            @Override
            public List<Patients> fetchLazyData(int first, int pageSize) {
                System.out.println("fetchLazyData called for PatientsMB");
                return ptFacade.findRange(first, pageSize);
            }
        };
        System.out.println("Count " + ptFacade.count());
    }

    public Patients getItem() {
        System.out.println ("get " + item.getFullname());
        return item;
    }

    public void setItem(Patients item) {
        System.out.println("Set " + item.getFName());
        this.item = item;
    }

    public List<Patients> getItemList() {
        itemList = ptFacade.findAll();
        System.out.println("GetItemList called");
        return itemList;
    }

    public void setItemList(List<Patients> itemList) {
        this.itemList = itemList;
    }

    public LazyDataModel<Patients> getLazyModelPts() {
        System.out.println("LazyDataModel<Patients> called");
        return lazyModelPts;
    }

    public void setLazyModelPts(LazyDataModel<Patients> lazyModelPts) {
        System.out.println("LazyDataModel<Patients set called");
        this.lazyModelPts = lazyModelPts;
    }

    public PatientsFacade getPtFacade() {
        return ptFacade;
    }

    public void setPtFacade(PatientsFacade ptFacade) {
        this.ptFacade = ptFacade;
    }

    public Patients getSelected() {
        System.out.println("getSelected " + selected.getFullname());
        return selected;
    }

    public void setSelected(Patients selected) {
        this.selected = selected;
    }

    public int getSelectedItemIndex() {
        return selectedItemIndex;
    }

    public void setSelectedItemIndex(int selectedItemIndex) {
        this.selectedItemIndex = selectedItemIndex;
    }
}
PF 3.5
NetBeans 7.2.1
GF 3.1.2
Mojarra 2.1.17

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

22 Aug 2010, 21:14

No mistake, lazy loading is not implemented yet for current 2.2.M1 build as stated in;

http://www.primefaces.org/labs/ui/datatableHome.jsf

grenadadoc
Posts: 34
Joined: 23 Mar 2010, 15:58

22 Aug 2010, 21:17

Thanks for the quick reply.

I thought since lazy loading was working in 2.0.2, that it would be working in 2.2 -- I thought just the lazy sorting/filtering were not working...
PF 3.5
NetBeans 7.2.1
GF 3.1.2
Mojarra 2.1.17

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

27 Aug 2010, 03:19

Initial implementation of new lazy loading feature for 2.2.M1;

http://www.primefaces.org/labs/ui/datatableLazy.jsf

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests