Tuesday 15 April 2014

Pagination in jsp without any jquery or js -


I need a pagination link, previous next next , previous 11- 20 Next etc. I have an array list, which is an asterisk and has 300 records, I need to show the first 10 records first. After clicking on the next 10, I have to show the next 10.

Can anyone share links or have any such ideas of resources?

  ArrayList arList = new ArrayList); ArList = // to retrieve calling method elements // table starts here & lt; Table ID = "TBL" & gt; For (int i = 0; i & lt; arList.size (); i ++) {Hashmap Hmap = (hashmap) arList.get (i); FirstVal = (string) hMap.get ("first"); SecondVal = (string) hMap.get ("second"); % & Gt; & Lt; TR & gt; & Lt; TD & gt; // First Val and Secondwol goes here & lt; / Tr & gt; & Lt; / Td> & Lt;%} & lt; / Table & gt;    

You can use JSTL for it !!

  & lt;% @ taglib prefix = "c" yuris = "http://java.sun.com/jsp/jstl/core"% & gt; ... & lt; C: forEach item = "$ {list}" var = "item" start = "0" end = "9" & gt; $ {Item} & lt; / C: forEach & gt;   

You can also use EL in those attributes.

  request.setAttribute ("firstrow", 0); Request.setAttribute ("rowcount", 10) & l: c: forEach item = "$ {list}" var = "item" start = "$ {firstrow}" end = "$ {firstrow + rowcount - 1}" & Gt; $ {Item} & lt; / C: forEach & gt;    

No comments:

Post a Comment