Move pagination to template.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 22 Oct 2010 09:46:44 +0000 (11:46 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 22 Oct 2010 09:46:44 +0000 (11:46 +0200)
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/resources/templates/index.html

index 67d11c6..47f2715 100644 (file)
@@ -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<Post> postPagination = new Pagination<Post>(allPosts, 25).setPage(page);
-               List<Post> postsOnPage = postPagination.getItems();
-               template.set("posts", postsOnPage);
-               template.set("pagination", postPagination);
+               template.set("posts", allPosts);
        }
 
        //
index 4c21bf6..fc8eedb 100644 (file)
@@ -3,8 +3,10 @@
        <h1><%= Page.Index.PostList.Title|l10n|html></h1>
 
        <div id="posts">
+               <%getpage>
+               <%paginate list=posts pagesize=2>
                <%include include/pagination.html>
-               <%foreach posts post>
+               <%foreach pagination.items post>
                        <%include include/viewPost.html>
                <%foreachelse>
                        <div><%= Page.Index.PostList.Text.NoPostYet|l10n|html></div>