• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pagination with MyFaces (JSF Newbie)

 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using MyFaces (JSF 2.0) and I want to paginate through a dataTable. I have the following code..



Now with the rows attribute I was able to limit the data to 10 per page, but the more challanging question is how do I actually paginate. How do I make the next and previous buttons to appear and how to make them work?

Thanks in advance for any help.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyFaces Tomahwak has a pagination control that can be attached to a dataTable.
 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for pointing me in this direction. I believe the dataScroller tag is what you are talking about. I included it in my page with the code below...



But when I run it still nothing is showing up. When I look at the HTML source of my rendered page, I see that the tag is not being interpreted (meaning it is appearing as t:dataScroller even in the browser source). Do I need to add any additional configuration files to my WEB-INF make this work, so far all I added was the tomhawk namespace to my xhtml page ...

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main thing is to make sure that the tomahawk jar is included in WEB-INF/lib.

One quirk that the Tomahawk datascroller had was that it only worked when placed under the dataTable on the page. I haven't used it in a while, however, so I don't know if that limitation still applies or not.
 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

I added the Tomahawk jar and now the pagination controls for the dataScroller show up. However pagination still does not work. It is failing in some of the Javascript code that it generated...

It looks like the way dataScroller works is by calling a Javascript method that it created called "oamSubmitForm"...



And it passes linkDummyForm as an argument, but nowhere in the page is there any form by that name, so when it comes this line it fails...



Thanks again for your help.
 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

I figured it out, I tried wrapping both the dataTable and the dataScroller in a form and that worked. So it looks like dataScroller needs to be part of a form to work.

Thanks,
Jehan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic