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

Pagination through Struts2 Action Classes

Nirmal Jatania
Greenhorn

Joined: Apr 17, 2009
Posts: 19
I am working on application using Spring, Struts2, Hibernate. Now i have completed Spring Configuration with Hibernate Mapping using MVC Architecture.

Now i am working on View Side using Struts2 Action Classes. I want to apply pagination concept in my all d forms. For e.g. if i have 1000 records in my table, then it should display me 100 pages & each page contains 10 records.

Anyone have proper logic for that ? Thanks in advance...
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Hi,

Why you want to develop your own logic for pagination.

There are already one third party tool available which makes your life easy.

This is wonderful tool or say application which you can integrate to your application for paging your page.

I give you the link for that.

First refer it and if you find any difficulty then let me know ........

http://displaytag.homeip.net/displaytag-examples-1.1/

you can find example here for different type of pagination.



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Nirmal Jatania
Greenhorn

Joined: Apr 17, 2009
Posts: 19
Hi, Nishan

Thanks for your response.

Ya, i gone through with d DisplayTag Lib 1.2 & execute its in built application too.

I understood the inbuilt property of displayTag. But i am still confuse that how to integrate it with struts2 action class.

I have already created action class of struts2. But don't know how to integrate displayTag with struts2 Action Classes.

Can you please provide me any link of example that show me the integration of both ? or any code that could help me...

Thanks in advance....

Nirmal.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689



Hi,

You don't have to make more configuration.

Just add display tag jar in your project.

In action just set your list which you want to display at your application.

After add taglib directive at your jsp then you can use the tag of display tag.


Just give your list name to your display tag table element list="your list name" .

Then use <display: column tag and use property for display it.


>
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


For better understanding use this


http://displaytag.sourceforge.net/10/install.html


Nirmal Jatania
Greenhorn

Joined: Apr 17, 2009
Posts: 19
Hello Nishan,

As you suggested i have gone through with tutorial of DisplayTag.

At the time of running my application, i am getting some error like :

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax.servlet.ServletException: Exception: [.LookupUtil] Error looking up property "id" in object type "java.lang.String". Cause: Unknown property 'id'

root cause

javax.servlet.ServletException: Exception: [.LookupUtil] Error looking up property "id" in object type "java.lang.String". Cause: Unknown property 'id'

root cause

Exception: [.LookupUtil] Error looking up property "id" in object type "java.lang.String". Cause: Unknown property 'id'

root cause

java.lang.NoSuchMethodException: Unknown property 'id'

note The full stack traces of the exception and its root causes are available in the Sun GlassFish Enterprise Server v2.1 logs.



My startup page of jsp is welcome.jsp. It has following code :



It works fine & calls the action class called as allCountry.action. That action class has following code :



Now SUCCESS is redirecting my application to country.jsp. That is the file where i want to apply pagination. It has following code :



Any Idea.... Please reply soon... Thanks in advance...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Doesn't displaytag require that the list is in a JEE scope?
Dejan Mratinkovic
Ranch Hand

Joined: Nov 20, 2008
Posts: 65
Nirmal,

It seems like your display tag did not locate your list properly, it seem to be iterating over String array, instead of Country one. At this point method:

getCountryList() should be called. Any chance you have method with this name returning list of Strings (as so logs indicate)?

Btw. requestURI seem not to be valid. You should put either valid uri, or leave it blank.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pagination through Struts2 Action Classes