import java.util.List;
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;
super.processTemplate(request, dataProvider);
List<Sone> knownSones = new ArrayList<Sone>(webInterface.getCore().getSones());
Collections.sort(knownSones, Sone.NICE_NAME_COMPARATOR);
- dataProvider.set("knownSones", knownSones);
+ Pagination<Sone> sonePagination = new Pagination<Sone>(knownSones, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
+ dataProvider.set("pagination", sonePagination);
+ dataProvider.set("knownSones", sonePagination.getItems());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void postProcess(Request request, DataProvider dataProvider) {
+ super.postProcess(request, dataProvider);
+ @SuppressWarnings("unchecked")
+ List<Sone> sones = (List<Sone>) dataProvider.get("knownSones");
+ for (Sone sone : sones) {
+ webInterface.getCore().markSoneKnown(sone);
+ }
}
}
<h1><%= Page.KnownSones.Page.Title|l10n|html></h1>
<div id="known-sones">
- <%getpage parameter=page>
- <%paginate list=knownSones pagesize=25>
<%= page|store key=pageParameter>
<%include include/pagination.html>
<%foreach pagination.items sone>