3

I'm using display tag to display my result set. Here's how I implement it.

<display:table name="w" pagesize="10"  export="true" />

Here I've set pagesize =10 and when I run the app , the records are paged to size 10 but when I click on the next page to view the next set of records, I get an empty result set.

E.g if there are 12 records, 10 of them are displayed in the first page and when I click on next to view the last page, I get an empty page. Why is this happening??

w contains a list of all my records :

request.setAttribute("w", resultrechparcritere);
Tiny
  • 27,221
  • 105
  • 339
  • 599
user3333294
  • 35
  • 1
  • 2
  • 8
  • Personally, I don't use *display tag* to display data in a tabular format (also in a page-wise manner). Although it facilitates to implement paging, it gives a lot of troubles, when we need something different than its standard. This may result in wasting of time unnecessarily. Moreover, the concept of paging should be done directly on the back-end database in question which should not happen after getting a full list of rows from that database. – Tiny Feb 20 '14 at 15:42
  • @user3333294: don't try to edit my answer to answer me, use comments instead. If now your problem is that the query is re-run on each action call, this is another problem and then another question should be opened, since this question is about a non-working pagination, and I made it work. You should also accept the answer by marking the V in the top left corner of the answer. And taking a little tour here: http://stackoverflow.com/tour – Andrea Ligios Feb 20 '14 at 16:42
  • because displaytag's pagination works through requests, then the action will be recreated each time. If you want to prevent a query to database for each request, put your resultset in session the first time, and retrieve it later. ALSO read my previous message. Different problem = new question, and please accept this one since it has worked – Andrea Ligios Feb 20 '14 at 17:12
  • finally i resolved it by a sessionscope in action class: UserForm userForm = (UserForm) form; userForm.setResultrechparcritere(resultrechparcritere); return mapping.findForward(SUCCESS_RESEARCH); – user3333294 Feb 24 '14 at 09:22
  • Your working JSP code is exaclty like mine (in original question you started with an empty table, after my answer you added `requestURI`, `keepStatus`, `uid`)... the strange things you do serverside should not affect the fact that the answer is correct, then think about accepting it... – Andrea Ligios Feb 24 '14 at 10:02

1 Answers1

2

The table must be able to contact the Action when handling the pagination,

then you have to include requestURI, along with (the not-mandatory fields, if I remember well) keepStatus and uid:

<display:table requestURI = "myActionURL" 
               keepStatus = "true" 
                 pagesize = "10"  
                     name = "w" 
                      uid = "myTable" 
                   export = "true" />

Then, you can even intercept and tweak / hack the pagination parameters by yourself, to programmatically reach a specific page.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243