Move the pagination out of the HTML. This fixes #51.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 13 Jan 2011 14:52:23 +0000 (15:52 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 13 Jan 2011 18:08:40 +0000 (19:08 +0100)
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/resources/templates/index.html

index 825267b..b0a27f7 100644 (file)
@@ -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<Post> pagination = new Pagination<Post>(allPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
+               dataProvider.set("pagination", pagination);
+               dataProvider.set("posts", pagination.getItems());
        }
 
        /**
index 39d53f1..345f376 100644 (file)
@@ -5,8 +5,6 @@
        <h1><%= Page.Index.PostList.Title|l10n|html></h1>
 
        <div id="posts">
-               <%getpage>
-               <%paginate list=posts pagesize=25>
                <%= page|store key=pageParameter>
                <%include include/pagination.html>
                <%foreach pagination.items post>