• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Pagination in Spring Boot not working as expected?

 
Ranch Hand
Posts: 148
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm building small TODO project using JavaScript, Ajax and Spring Boot. I did make all CRUD operations, tested them and they work.

Now I blend in pagination using Spring Boot, like so:



I have following data:

Exactly six TODO records with their title from do a to do f, with indexes from 1 to 6.

The UI in the browser once the page first time loads (attachment 1).

Now, in JavaScript, I made some constructor function called Page, so I can keep reference on current page. Kinda to mimic static in Java.

It looks like this:



Now, once the page first time loads, I set property of prototype called pageNumber, as I explaind above. The first time loading of a page will bring me two TODOs object, along with information whether it is the last page or not.

Each time I click Load more todos button, "static" pageNumber variable increases and I get following two entities. Increasing of variable looks like this:




Here is the problem:

Once I click second time, on my UI I have do a, do b, do c and do d. Next I delete do b and do c. I do remove the from UI and logically delete the from database, like so:



Now in UI, I have do a and do d. Here comes the problem. In my database I'm sure I have do e and do f not deleted, but once I click for the second time on Load more button, the pageNumber is equal to 2 (which is okey) and in my response I get that the page is last, but I get an EMPTY Json array! Drives me nuts!

Next, if I load page one more time, those last two elements do e and do f get fetched from db.

Here is how my Ajax GET request looks like:




These is the function which gets called on button click:




Screenshot_1.png
[Thumbnail for Screenshot_1.png]
Screenshot_2.png
[Thumbnail for Screenshot_2.png]
 
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not quiet sure what is going on with do e and do f after you delete a, b, c, d and you have to load the page for a second time to see them.
Maybe, try to use non-Ajax and see ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic