Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pagination in Spring using WebServices  RSS feed

 
Manu mayank
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am stuck in the middle of nowhere. I have to apply pagination in SPRING MVC3.

Now we get the list of items to be populated on the jsp page from a controller. Now how should I apply pagination on that list so that limited number of records are shown on the JSP?
Please don't send me the link to other sides because I am unable to understand their example.

What do I have?
1) I have a list which I get from a controller.
2) List is populated on jsp in rows.

How should I proceed. Explain in simple terms, I am really struggling my project.
Regards,
Mayank
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually pagination is done at the model layer. Which spring technology are you using to implement your model?
 
Manu mayank
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Spring framework with portlet.

What do you mean by Model layer? Can you tell me with the help of an example?
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you going to access your database? Normally paging is done by telling the database to limit the number of records being retrieved. As the user advances in pages, you change the limits. Now, the problem is, each flavor of SQL has its own way of specifying limits. JPA isolates you from the database. You will need to specify the starting row and ending row. And it will construct the database query itself.

So, the specifics of your answer depends on what you are going to use to access the database? Are you going to use JDBC? Are you going to use Hibernate? JPA? Spring Data? You'll find examples for all of these in the spring docs. You need to decide which ones work for you. My personal preference is to use Spring Data.

Here's some documentation on spring data http://docs.spring.io/spring-data/data-commons/docs/current/reference/html/repositories.html
 
Manu mayank
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for the link.

I am really struggling to take this forward.

I have a list of a specific object. I am not connecting to database or anything. I have a list of object which has all the data. I can show the data in that list on a jsp. I just need to apply pagination on that object. Can this be done?

Thanks for replying to my queries.
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh! No, database

You could use List.sublist http://docs.oracle.com/javase/6/docs/api/java/util/List.html#subList(int,%20int)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!