paging

table one

no | nama | address

1 another another

2 another another

...

...

50 another another

table two

no | nama | address

51 another another

52 another another

...

...

60 another another

how paging table if i click some link to show table one

and i click some link (same link) show table two like in up sorry

[408 byte] By [ba12yua] at [2007-11-26 13:00:10]
# 1

i think so u want to do pagination,

a eg of jsp code,

<%

String startIndex ="";

String index ="";

String indexPage ="";

String indexCount ="";

String tempCount ="";

int indexLoop = 0;

int indexSelected =0;

if(null != request.getAttribute("startIndex")) {

startIndex = request.getAttribute("startIndex").toString();

}

if(null != request.getAttribute("indexCount")) {

indexCount = request.getAttribute("indexCount").toString();

if("0".equals(request.getAttribute("indexCount").toString())){

startIndex = "0";

}

}

if(null != request.getAttribute("index")) {

index = request.getAttribute("index").toString();

}

if(null != request.getAttribute("indexSelected")) {

tempCount = request.getAttribute("indexSelected").toString();

indexSelected=Integer.parseInt(tempCount);

}

if(null != request.getAttribute("indexPage")) { %>

<input type="hidden" name="indexPage" id="indexPage" value="0" />

<%

indexPage = request.getAttribute("indexPage").toString();

indexLoop=Integer.parseInt(request.getAttribute("indexPage").toString());

%>

<%}%>

<table cellpadding="3" cellspacing="0" width="100%" border="0" id="paginationTop">

<%if(null != request.getParameter("i")) %>

<tr>

<td class="navResults">

Results <%=startIndex%> - <%=index%> of <%=indexCount%>

</td>

<td class="navResults" align="right">

<%for(int loop=0;loop<(indexLoop);loop++){%>

<a href="#" onclick="return selectProductIndex(<%=(loop+1)%>);" ><%if((loop+1)==indexSelected ){%>[<%}%><%=(loop+1)%><%if((loop+1)==indexSelected ){%>]<%}%></a>

<span class='navResultsDim'> </span>

<%}%>

</td>

</tr>

</table>

--

pass the start index and end index , ie., the data retrived from the table.

if there are 1000 record in the table ,

start index is 0 and end index is 1000.

set the no of results to be shown in a page.

there will be numbers displayed at the top like ,

1 2 3 4 >>

clicking on it it shows the next page.

Selvaganapathya at 2007-7-7 17:00:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...