The usage of Repeater taglib

This file contains a sample for Repeater taglib. Here we will create a list of items with paging. For paging support we will use Pager taglib from Coldtags suite. How it looks like? In our case we will have a simple array that will be formatted as a list. And we will output just 2 rows per page:

<html>

<!-- Repeater taglib -->
<%@ taglib uri="taglib114.tld" prefix="list" %>

<!-- pager taglib -->
<%@ taglib uri="taglib139.tld" prefix="pg" %>

<!-- our data -->
<%
  String s[]={"apple","orange","pear","cherry"};
%>

<!-- describe paging. Size is 2 records -->
<pg:paging pageSize="2">

<!-- our list -->
<list:Repeater source="<%=s%>">

<pg:item invokeAll="false">
  <list:itemTemplate><%=CURRENT_VALUE%></list:itemTemplate>
  <list:alternatingItemTemplate><em><%=CURRENT_VALUE%></em></list:alternatingItemTemplate>
  <list:separatorTemplate><br></list:separatorTemplate>

  <list:headerTemplate><center><b>Repeater with paging</b></center></list:headerTemplate>
  <list:footerTemplate><center><b>End of page</b></center></list:footerTemplate>
</pg:item>
</list:Repeater>

<!-- index -->
<pg:index title="Pages:">
  <pg:page><%=thisPage%></pg:page>
</pg:index>

</pg:paging>

</html>

and you will get some like this:

Repeater with paging

pear
cherry
End of page
Pages: 1  2

 © Coldbeans   Comments?

See also Other tips from Coldbeans.