The usage of DataList taglib

This file contains a sample for DataList 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:


<!-- DataList taglib -->
<%@ taglib uri="taglib73.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:DataList source="<%=s%>">

<pg:item invokeAll="false">

  <list:headerTemplate><center><b>DataList with paging</b></center></list:headerTemplate>
  <list:footerTemplate><center><b>End of page</b></center></list:footerTemplate>

<!-- index -->
<pg:index title="Pages:">



and you will get some like this:

DataList with paging

End of page
Pages: 1  2

 © Coldbeans   Comments?

See also Other tips from Coldbeans.