I just tried 30,000 entries and everything worked out fine. However, it is worth noting that the getMyList method is called many times (6 in my case in the rendering response phase), and each time it is called your bean, it selects / generates a new list, and this may be the part that caused the problem (although I tried to create a new list in my getter method, but it worked fine).
Generally speaking, it is recommended that you do not specify codes related to business logic. Instead, in many cases, it would be better to populate the list in the @PostConstruct method or elsewhere. Please see Post made by BalusC and this may be helpful. Why JSF calls getters several times Also you can read this for lazy loading Effective JSF breakdown
Below are my test codes:
<h:body> <h:form> <p:dataTable id="dataTable" var="car" value="#{tableBean.cars}" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"> <f:facet name="header"> Ajax Pagination </f:facet> <p:column> <f:facet name="header"> <h:outputText value="Model" /> </f:facet> <h:outputText value="#{car.model}" /> </p:column> <p:column> <f:facet name="header"> <h:outputText value="Manufacturer" /> </f:facet> <h:outputText value="#{car.manufacturer}" /> </p:column> <p:column> <f:facet name="header"> <h:outputText value="Other Information" /> </f:facet> <h:outputText value="#{car.otherInformation}" /> </p:column> </p:dataTable> </h:form> <ui:debug hotkey="x"/> </h:body>
And this is bean support:
@ManagedBean @RequestScoped public class TableBean implements Serializable { private List<Car> cars; @PostConstruct public void init() { System.out.println("A new backing bean has been created"); cars = new ArrayList<Car>(); populateRandomCars(cars, 300000); } private void populateRandomCars(List<Car> list, int size) { for (int i = 0; i < size; i++) { list.add(new Car(i, i, UUID.randomUUID().toString())); } } public List<Car> getCars() {
And finally, the model class:
public class Car { private int manufacturer; private int model; private String otherInformation; public Car(int manufacturer, int model, String otherInformation){ this.manufacturer = manufacturer; this.model = model; this.otherInformation = otherInformation; }
source share