From a4ec77c6eb6d56e4ea7a8829ab50b199c18cbe87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Jan 2011 15:52:23 +0100 Subject: [PATCH] Move the pagination out of the HTML. This fixes #51. --- src/main/java/net/pterodactylus/sone/web/IndexPage.java | 6 +++++- src/main/resources/templates/index.html | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/IndexPage.java b/src/main/java/net/pterodactylus/sone/web/IndexPage.java index 825267b..b0a27f7 100644 --- a/src/main/java/net/pterodactylus/sone/web/IndexPage.java +++ b/src/main/java/net/pterodactylus/sone/web/IndexPage.java @@ -24,6 +24,8 @@ import java.util.List; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.util.collection.Pagination; +import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.template.DataProvider; import net.pterodactylus.util.template.Template; @@ -72,7 +74,9 @@ public class IndexPage extends SoneTemplatePage { } } Collections.sort(allPosts, Post.TIME_COMPARATOR); - dataProvider.set("posts", allPosts); + Pagination pagination = new Pagination(allPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0)); + dataProvider.set("pagination", pagination); + dataProvider.set("posts", pagination.getItems()); } /** diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 39d53f1..345f376 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -5,8 +5,6 @@

<%= Page.Index.PostList.Title|l10n|html>

- <%getpage> - <%paginate list=posts pagesize=25> <%= page|store key=pageParameter> <%include include/pagination.html> <%foreach pagination.items post> -- 2.7.4