Author: andre
Date: 2010-07-09 20:21:05 +0200 (Fri, 09 Jul 2010)
New Revision: 42851

Added:
   mmweb/trunk/src/main/webapp/WEB-INF/tags/mmweb/pager.tagx
Log:
pager copied from oip


Added: mmweb/trunk/src/main/webapp/WEB-INF/tags/mmweb/pager.tagx
===================================================================
--- mmweb/trunk/src/main/webapp/WEB-INF/tags/mmweb/pager.tagx                   
        (rev 0)
+++ mmweb/trunk/src/main/webapp/WEB-INF/tags/mmweb/pager.tagx   2010-07-09 
18:21:05 UTC (rev 42851)
@@ -0,0 +1,65 @@
+<jsp:root 
+  xmlns:jsp="http://java.sun.com/JSP/Page";
+  xmlns:c="http://java.sun.com/jsp/jstl/core";
+  xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0";
+  version="2.0">
+
+  <jsp:directive.attribute name="total"  type="java.lang.Integer"
+                           description="Total number of results in list" />
+  <jsp:directive.attribute name="max"    type="java.lang.Integer"
+                           description="Maximum items per page" />
+  <jsp:directive.attribute name="offset" type="java.lang.Integer"
+                           description="Page offset" />
+  <jsp:directive.attribute name="baseurl"
+                           description="Url with needed parameters" />
+  <jsp:directive.attribute name="fragment"
+                           description="Fragment part of the url, to switch to 
the right tab f.e." />
+  
+  <c:if test="${total > max}">
+    <c:if test="${offset != 0}">
+      <!-- mm:link referid="baseurl">
+        <mm:param name="offset">0</mm:param>
+        <mm:param name="max">${max}</mm:param>
+        <a href="${_}" class="first">first</a>
+      </mm:link> <jsp:text> </jsp:text> -->
+      <mm:link referid="baseurl">
+        <mm:param name="offset">${offset - max}</mm:param>
+        <mm:param name="max">${max}</mm:param>
+        <a href="${_}${empty fragment ? '' : fragment}" class="previous">«« 
previous</a>
+      </mm:link> <jsp:text> </jsp:text>
+    </c:if>
+    
+    <c:set var="pages" value="${(total / max)}" />
+    <c:forEach var="index" begin="0" end="${pages}">
+      <c:choose>
+        <c:when test="${(index * max) == offset}">
+          <c:if test="${pages gt 1}">
+            ${(index + 1)} <jsp:text> </jsp:text>
+          </c:if>
+        </c:when>
+        <c:otherwise>
+          <mm:link referid="baseurl">
+            <mm:param name="offset">${(index * max)}</mm:param>
+            <mm:param name="max">${max}</mm:param>
+            <a href="${_}${empty fragment ? '' : fragment}">${(index + 1)}</a> 
<jsp:text> </jsp:text>
+          </mm:link>
+        </c:otherwise>
+      </c:choose>
+    </c:forEach>
+    
+    <c:if test="${(total - offset) > max}">
+      <jsp:text> </jsp:text> 
+      <mm:link referid="baseurl">
+        <mm:param name="offset">${offset + max}</mm:param>
+        <mm:param name="max">${max}</mm:param>
+        <a href="${_}${empty fragment ? '' : fragment}" class="next">next 
»»</a>
+      </mm:link>
+      <!-- <jsp:text> </jsp:text> <mm:link referid="baseurl">
+        <mm:param name="offset">${total - (total mod max)}</mm:param>
+        <mm:param name="max">${max}</mm:param>
+        <a href="${_}" class="last">last</a>
+      </mm:link -->
+    </c:if>
+  </c:if>
+
+</jsp:root>

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to