Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9031479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:44:32+00:00 2026-06-16T07:44:32+00:00

I have a application using JSF2.0, Spring3 and Hibernate4. I am displaying values in

  • 0

I have a application using JSF2.0, Spring3 and Hibernate4.

I am displaying values in Primefaces 3.4.2 datatable, the problem is when I click the pagination, datatable rows always remain in first 10 records. It doesn’t displays next 10 records.

My datatable code

<h:form>
        <p:dataTable id="dataTable" var="req" value="#{reqMB.myList}"
            paginator="true" rows="10"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="5,10,15">
            <f:facet name="header">          

        </f:facet>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="XXX" />
                </f:facet>
                <h:outputText value="#{req.bbbb}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                    <h:outputText value="XXXXS" />
                </f:facet>
                <h:outputText value="#{req.kkjj}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                    <h:outputText value="XXXXXOO" />
                </f:facet>
                <h:outputText value="#{req.nnnn}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                    <h:outputText value="XXXXKK" />
                </f:facet>
                <h:outputText value="#{req.kkkk}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                    <h:outputText value="XKKKK" />
                </f:facet>
                <h:outputText value="#{req.pppp}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                    <h:outputText value="LLLL" />
                </f:facet>
                <h:outputText value="#{req.llll}" />
            </p:column>
        </p:dataTable>
    </h:form>

ManagedBean

@Named("reqMB")
@Scope("request")
public class MyBean implements Serializable {

    private static final long serialVersionUID = 1L;

    @Inject
    MyService myService;

    List<MyClass> myList;


    public List<MyClass> getMyList() {
        try {
            myList= new ArrayList<MyClass>();
            myList.addAll(getMyService().getMymethod());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return myList;
    }

How can I resolve this issue?

Update 1

I have noticed that when I display few number of records pagination works fine, but when I display records more than 1300, then pagination doesn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:44:33+00:00Added an answer on June 16, 2026 at 7:44 am

    I just tried 30000 records and it worked ok. One thing worth noticing though is that the getMyList method gets called many times (6 in my case in render response phase)and each time it is called your bean fetch/generate a brand new list, and that may be the part that is causing the problem (Although I tried to generate a new list in my getter method but it worked OK).

    Generally speaking it is recommended not to put any business logic related codes there. Instead in many cases it would be better to populate the list in your @PostConstruct method or somewhere else. Please see the post made by BalusC and it may be helpful.
    Why JSF calls getters multiple times
    Also you can read this for lazy loading
    Efficient JSF Pagination

    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 the backing bean:

    @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() {
    //If i populate the list here I can still get the correct result.
    //        cars = new ArrayList<Car>();
    //        populateRandomCars(cars, 30000);
            return cars;
        }
    
        public void setCars(List<Car> cars) {
            this.cars = cars;
        }
    }
    

    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;
        } 
    
        //Getters and Setters 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small application using Spring3, Hibernate4 and JSF2. So far in my
I am using Hibernate4,Spring3 and JSF2 for a small application and Weblogic 10.3.6 as
I am running an application using JSF2.0 and Primefaces 2.2RC2 I have run the
I am using JSF2.0 with Richfaces 4.0.0.Final for a web application. I have a
My JSF2 application is fully internationalized, using a ResourceBundle. Now i have a lot
I have created web-application using JSF 2.0 & JSP and facing some weird problem.
I have written a jsf2 (cdi) web-application, using jQuery, a syntaxhighlighting script lib. On
I'm using RichFaces on my JSF2 application, and I need a way to have
I have an application developed using Primefaces 2.2.1 and JSF 2.0, deployed on Glassfish
I have my application using jQuery heavily. The problem is that we started with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.