velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kishore Senji <kse...@gmail.com>
Subject Re: Paging database results
Date Wed, 04 Aug 2004 21:13:35 GMT
Your foreach depends on $oldProductsList. Since empty results are
displayed, the first thing to check would be
if $resultsTableUtils.getOldResultsByNum($startNo) is returning any
empty results.


On Wed,  4 Aug 2004 21:37:44 +0100, N Kaikis <liq03nk@sheffield.ac.uk> wrote:
> Hi all,
> 
> I'm a bit new to mailing lists and to Velocity,but I have a small
> problem.Basically,I'm trying to page some results(around 224) that come from a
> table in my database.Let me give you my code first:
> 
> Page:  $page, page size: $pageSize, Start Number: $startNo, End Number: $endNo,
> Page number: $pageNo, Total Number of pages: $pageCount
> #set($oldProductsList=$resultsTableUtils.getOldResultsByNum($startNo))
> #set($recordNum=$resultsTableUtils.getRecordsNum($startNo))
> <TABLE cellspacing="0" cellpadding="0" border="0" align="center">
> #foreach ($oldProductsRow in $oldProductsList)
>  #set($url=$resultsTableUtils.getElement($oldProductsRow,1))
>  #set($count=$startNo+$velocityCount)
>  #set($count=$count-1)
>    <TR>
>    <TD ALIGN="left" bgcolor="#CD853F"><STRONG>
>      $count.</STRONG>
>      </TD>
>    #foreach ($oldProductsItem in $oldProductsRow)
>    </TR>
>    <TR>
>        <TD ALIGN="left">
>          #if($oldProductsItem==$url)
>            <a href="$oldProductsItem">$oldProductsItem<BR></TD>
>          #else
>            $oldProductsItem<BR>
>          #end
>       </TD>
>    #end
>      </TR>
>      <TR>
>      <TD></TD>
>      <TD></TD>
>      </TR>
>      #end
>     #if($pageNo!=$pageCount)
>    <TR>
>    <TD></TD>
>    <TD>
>    <a href="/ecommerce/servlet/Controller?event=ReturnOldProducts">>>Next
30
> results</a>
>    </TD>
>    </TR>
>    #end
> </TABLE>
> 
> where all the variables appearing on the first line come from the session.The
> $pageSize=30,so that each page contains 30 results and I'm querying the
> database each time to give me the next 30 results,by checking the startNo
> variable.
> My problem is,that,when I'm on the last page of my results,although there are
> only 4 results remaining to display,Velocity displays 30 results with 26
> results being empty.
> I have searched the Internet a lot,but nothing helpful came up.Any kind of help
> would be valuable    :)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message