You could achieve a back button by using a similar scheme (selecting  
pageSize+1) and ordering descending.

eg, Say you had an index field with entries "index1", "index2", etc.  
Gaps would be fine (but assume none in this example). Say the page  
size is 10.

First page you just select the first ten items, with index1 to  
index10. The next button would have "?start=index10&order=asc" (you  
could assume the default order to be "asc"). On the next page, you  
would select pageSize+1 (11) items >= index10 in ascending order,  
remove the first (index10) and display the rest (index11 to index20).  
The "Prev" link on this page would be "?start=index11&order=desc" and  
the "Next" link would be "?start=index20&order=asc". If you clicked  
"Prev", it would (based on order="desc") select 11 items <= index11 in  
descending order, remove the first (index11), reverse the rest and  
display (index1 to index10).

You still wouldn't be able to show links to each numbered page (only  
prev/next) - however, if you selected, say (pageSize*5)+1 items (and  
adjust the start offset accordingly), then you could show links to the  
prev three and next three pages. If you also kept track of the page  
number you were on (for the sake of link names), then you could come  
pretty close to achieving standard paging functionality (first and  
last pages could be done by selecting without a filter, asc or desc).

Cheers,

Michael

On 20/11/2008, at 8:40 AM, Alexander Kojevnikov wrote:

>
> I use Brett Slatkin's technique: in the model I page over, I have a
> string property called "order". It's a composite string and it's
> guarantied to be unique.
>
> When querying for entities, I ORDER BY this property. If I want to
> have 20 entities per page, I fetch 21 entities, show 20 of them and
> use 21st's "order" in the "Next >>" link: /mypage?next=order
>
> The "next" parameter is used in the query to skip entities: "WHERE
> order >= :next"
>
> This allows to page as far as user wants without much burden on the
> datastore. The only downside is that it's not possible to page back,
> but alas, that's what the browser's "Back" button is for!
>
> Alex
> --
> www.muspy.com
>
> On Nov 20, 3:38 am, "Abel Rodriguez" <[EMAIL PROTECTED]> wrote:
>> I am currently doing a detailed study on how to optimize my
>> application to be scalable.
>>
>> I have thoroughly studied the lectures delivered by the engineers at
>> google, and my opinion: fantastic
>>
>> In this case, my question comes from the presentation
>>
>> Buildding Scalable Web Applications with Google App Engine whose
>> rapporteur was Brett Slatkin
>>
>> In it, in the section "Building a Blog: Paging ", using the attribute
>> index, get to paginate infinite elements, using the index as a guide
>> for the next entry
>>
>> Now, suppose you delete an entity, the attribute index would not be
>> consecutive. taking into account that, any idea howto  implement
>> paging that supports not only next and previous, but also, goto "n"
>> page number.?
>>
>> thanks in advance,
>>
>> Abel
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to