• Post Reply Bookmark Topic Watch Topic
  • New Topic

paging concept  RSS feed

 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi


in my forum ,employee names will be stored in vector;i want to display those names as paging;per page i want to display 5 records;i want to give next ,previous buttons;these values r not coming from database;
how to achieve simple paging in jsp;i searched the forum i didnt get good one;
[ June 22, 2004: Message edited by: kesava chaitanya ]
 
Krishna Srinivasan
Ranch Hand
Posts: 1879
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
store vector into session, then each time get the value from sesion and display it..
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kesava

If i am not wrong u want something like google shows after results.

It is quite a simple thing in Jsp

Have u hearsd abt Display taglib just download that from net

And u can use the following code for displaying ur records in pages

<display:table name= ur vector name which is comingin form or Request class="Data" id="row" requestURI="the class u r coming from " pagesize="5">
<display:column property="property of the object in list" title="Any heading for the column" />
</display:table>

try this out u have to download the tld for display that u will get on Sourcrforge.net or opensymphony.com

any futher help u can post here agian

Best Regards
Pankaj
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
take a look at the JSTL c:forEach tag which is the standardised way to do paging.
 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pankaj Narang:
Hi Kesava

If i am not wrong u want something like google shows after results.

It is quite a simple thing in Jsp

Have u hearsd abt Display taglib just download that from net

And u can use the following code for displaying ur records in pages

<display:table name= ur vector name which is comingin form or Request class="Data" id="row" requestURI="the class u r coming from " pagesize="5">
<display:column property="property of the object in list" title="Any heading for the column" />
</display:table>

try this out u have to download the tld for display that u will get on Sourcrforge.net or opensymphony.com

any futher help u can post here agian

Best Regards
Pankaj



if i add some names to my vector; i want to display those names;
i have used display tag lib like this ,but nothing can be found message is coming;
<%@ include file="init.jsp" %>

<%@ page import="java.util.*"%>
<%
Vector player = new Vector();
player.add("Sachin");
player.add("Ganguly");
player.add("Ramehs");
player.add("Sehwag");
player.add("Yuvraj");
player.add("Kaif");
player.add("Dravid");
%>
<display:table name="player" pagesize="10">
<display:column property="name" />
</display:table>
 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i downloaded the zip and able to run the war ;but i am not able to understand how to apply displaytag lib to my code ;is it necessary write bean file;
 
Krishna Srinivasan
Ranch Hand
Posts: 1879
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this very simple �..
File.jsp
========
<html>
<%
java.util.ArrayList a = new java.util.ArrayList();
for(int i = 0;i < 45;i++){
a.add(String.valueOf(i));
}
session.setAttribute("data",a);
%>

<jsp:forward page="another.jsp?status=0"/>

</html>
Another.jsp
============
<html>
<%
String status = request.getParameter("status");
int intVar = Integer.parseInt(status);
java.util.ArrayList al = (java.util.ArrayList)session.getAttribute("data");
%>
<form name="form1">
<table>
<%
for(int i = intVar*10;i<intVar*10+10;i++){
%>
<tr>
<td>
<%=al.get(i)%>
</td>
</tr>
<%
}
%>
</table>
<input type="button" value="next" >
<input type="text" value="<%=status%>" name="val">
</form>
<script>
function next(){
cp =parseInt(document.form1.val.value);
cp++;
window.location="another.jsp?status="+cp;
}

</script>
</html>
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!