• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Paging in JSP

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have 50 values those are comimg from database , but I want only 10 values show at a time and a link next. If I click next, I should go to other next 10 values and so on. How can I achieve it. Pls get back to me soon since I am stuck with problem.

Rajeev
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you search this forum, you should find that this question is asked all the time. You can find your solution that way.

Eric
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U need to fisrt include the jar -pager-taglib.jar in the lib of the WEB-INF folder

Try modifying this piece of code

---------------------------------------
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>


<pg ager
items="<%=DataSize %>"
index="<%= index %>"
maxPageItems="<%= maxPageItems %>"
maxIndexPages="<%= maxIndexPages %>"
isOffset="<%= true %>"
export="offset,currentPageNumber=pageNumber"
scope="request">

<pg aram name="style"/>
<pg aram name="position"/>
<pg aram name="index"/>
<pg aram name="maxPageItems"/>
<pg aram name="maxIndexPages"/>

<%
int pagemove=0;
if (offset.intValue()>DataSize){
pagemove=0;
}
else
{
pagemove= offset.intValue();
}

%>


<% if ("top".equals(position) || "both".equals(position)) { %>
<br>
<%
int currpg=pagemove+15;
%>
<font class = "firstlevel" size="2" > DISPLAYING RECORDS  <%=pagemove%>-<%=currpg%>/<%=DataSize%>    

<pg:index>

<pg:first>
<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=0%>"><nobr>[ First ] </nobr></a>
</pg:first>

<pg rev>
<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=pagemove-15%>"><nobr>[ Prev ] </nobr></a>
</pg rev>

<pg:next>

<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=pagemove +15%>"><nobr>[ Next ]  </nobr></a>
</pg:next>

<pg:last>
<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=DataSize-15%> "><nobr>[ Last ] </nobr></a></font>
</pg:last>

</pg:index>

<% } %>

/*************************/
<%

int a = 0;
if(DataSize<=0)
{%>
<TD colspan="10"><font class = "generalfont">  No records to Display</font></TD>
<%}
for (int i = pagemove,
l = Math.min(i + maxPageItems, DataSize);
i < l; i++)
{

%>

<tr>
<% System.out.println(((java.util.Properties)(TimeSheet.toArray()[i])).getProperty("status"));
if(((java.util.Properties)(TimeSheet.toArray()[i])).getProperty("status").equals("APPROVED")) { %>
<td><input name="timeid" type="checkbox" disabled="true" value=<%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("timeId")%>></td>
<%} else {%>
<td><input name="timeid" type="checkbox" value=<%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("timeId")%>></td>
<% }%>

<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("projName") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("taskName") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("activity") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("startTime") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("endTime") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("duration") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("status") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("date") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("Comment") %></font></TD>

</tr>

<pg:item>
</pg:item>
<%
}
%>
</pg ager>
-------------------------------------

Hope this is of some help

regards
Menon
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic