From 55135a2fbb98c7a17a9c4a080a5a1173704e7774 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 Oct 2010 11:46:44 +0200 Subject: [PATCH] Move pagination to template. --- src/main/java/net/pterodactylus/sone/web/IndexPage.java | 7 +------ src/main/resources/templates/index.html | 4 +++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/IndexPage.java b/src/main/java/net/pterodactylus/sone/web/IndexPage.java index 67d11c6..47f2715 100644 --- a/src/main/java/net/pterodactylus/sone/web/IndexPage.java +++ b/src/main/java/net/pterodactylus/sone/web/IndexPage.java @@ -24,7 +24,6 @@ import java.util.List; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.util.collection.Pagination; import net.pterodactylus.util.template.Template; /** @@ -69,11 +68,7 @@ public class IndexPage extends SoneTemplatePage { } }); - int page = request.getHttpRequest().getIntParam("page", 0); - Pagination postPagination = new Pagination(allPosts, 25).setPage(page); - List postsOnPage = postPagination.getItems(); - template.set("posts", postsOnPage); - template.set("pagination", postPagination); + template.set("posts", allPosts); } // diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 4c21bf6..fc8eedb 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -3,8 +3,10 @@

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

+ <%getpage> + <%paginate list=posts pagesize=2> <%include include/pagination.html> - <%foreach posts post> + <%foreach pagination.items post> <%include include/viewPost.html> <%foreachelse>
<%= Page.Index.PostList.Text.NoPostYet|l10n|html>
-- 2.7.4