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>
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;
}
}