aspose file tools*
The moose likes Spring and the fly likes Spring MVC Pagination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring MVC Pagination " Watch "Spring MVC Pagination " New topic
Author

Spring MVC Pagination

laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
What is the best way to implement pagination yet maintaining the Spring MVC methodology? Also, the dataset will not be coming from a database, it will be a hashmap that is set via the controller. Does anyone have any suggestions?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Moved to the Application Frameworks forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Again, We do have dedicated Spring Forum.
Stay updated
laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
oh, I'm sorry. Can my topic be moved there please?

Many Thanks.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
laura mccord wrote:What is the best way to implement pagination yet maintaining the Spring MVC methodology? Also, the dataset will not be coming from a database, it will be a hashmap that is set via the controller. Does anyone have any suggestions?

Thanks.


You mean to say it would fetch the data from database for only time?
laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
Well, my code is a listing of files/folders that are contained in a given directory path, so a database is not involved. But, once I retrieve all the contents load it in a HashMap, my controller sends the hashmap to my jsp page. I've seen so many examples that are using a database but I haven't seen anything where it's just a list or hashmap. So, I was wondering if this has been done before so I don't have to recreate the wheel.

Thanks
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
You might want to check Display Tag.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Check out the PagedListHolder class. This is a way to get the data and have a page size and sorting.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
Thanks for the suggestions.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
laura mccord wrote:Thanks for the suggestions.

Just curious, how did you apply the pagination?
laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
I actually haven't completed yet.I got sidetracked and I need to accomplish one more thing before I start messing with layout. I was just trying to get suggestions so I know what to start researching. I'll definitely post my result once I finish this step.

Thanks
Rahul Mishra
Ranch Hand

Joined: Jan 22, 2006
Posts: 211
I have used the DisplayTag earlier. If you google the forums you will find that it has been used with Spring MVC quite a bit.


Just download the sample WAR from display tag team , and see if the level of pagination supported in the examples suits your requirements (they have many examples showing various levels of customization to the tag).

What i liked about the tag is that it accepts a partial list (only what is to be displayed on the page) , this is a huge gain in terms of memory.

Check it out..


OCMJEA/SCEA, SCDJWS, SCBCD 1.3, SCJP 1.4
My SCEA experience:http://javalogue.blogspot.com/
laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
I installed the display tag jar in my webapp and I'm trying to use it correctly. I noticed first thing that I'm able to get my data from the hashmap but it's not building the columns/rows correctly.



Say I want the following to output:

NAME SIZE TYPE
Documents 12 Folder
Desktop 10 Folder
Pictures 9 Folder
Music 23 Folder

Instead, I'm getting the following output using the code snippet above:

NAME SIZE TYPE NAME SIZE TYPE NAME SIZE TYPE NAME SIZE TYPE
Documents 12 Folder Desktop 10 Folder Pictures 9 Folder Music 23 Folder
Documents 12 Folder Desktop 10 Folder Pictures 9 Folder Music 23 Folder
Documents 12 Folder Desktop 10 Folder Pictures 9 Folder Music 23 Folder
Documents 12 Folder Desktop 10 Folder Pictures 9 Folder Music 23 Folder
Documents 12 Folder Desktop 10 Folder Pictures 9 Folder Music 23 Folder

What am I doing wrong?

Thanks.


laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
Ugh, I finally got it after during trial and error:

This is what I was supposed to code:



My problem was that I was still trying to use my old jstl logic of traversing the HashMap and using this method for display:tag . But, display tag is much simpler.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring MVC Pagination