Paginator & empty collection, negative offset
a) When there is empty collection (0 items, nothing to iterate over)
then following [1]
def currentXml: NodeSeq = Text("Displaying records"+(first+1)+"-"+(first+itemsPerPage min count)+" of "+count)
calculates to
"Displaying records 1-0 of 0"
Does not look right to me, I would expect "Displaying records 0-0 of 0"
b) I'd suggest to split calculations away from
Text("Displaying records "+(first+1)+"-"+(first+itemsPerPage min count)+" of "+count)
so that it could be used via paginate() binding like
<nav:recordsFrom /> - <nav:recordsTo /> of <nav:recordsCount />
c) Calculation for "next" link [2]
"next" -> pageXml(first+itemsPerPage min itemsPerPage*(numPages-1), nextXml),
calculates negative value when 'numPages' is zero resulting
"next"-link to contain
?offset=-<itemsPerPage>
Expected: No link in case of empty collection (as there is for "prev")
d) Same problem for the "last" (as for "next", described previously)
e) More of a debatable robustness issue: I would expect the Paginator
offered by the framework to be smart enough that it could not result
in an error like
Message: org.postgresql.util.PSQLException: ERROR: OFFSET must
not be negative
(even when user plays with parameters on address bar)
[1] Line 102 at
http://github.com/lift/lift/blob/2.x-2.8_devel/framework/lift-base/lift-webkit/src/main/scala/net/liftweb/http/Paginator.scala
[2] Line 142 at
http://github.com/lift/lift/blob/2.x-2.8_devel/framework/lift-base/lift-webkit/src/main/scala/net/liftweb/http/Paginator.scala
Original thread: http://groups.google.com/group/liftweb/browse_thread/thread/50260536cebd0ae
Initially assigned to 'timperrett' because instructed so by 'dpp':
> Finally, Tim Perrett currently maintains the paginator. He's off-grid this week.
> [...] Tim will address the ticket when he has the bandwidth.
then following [1]
def currentXml: NodeSeq = Text("Displaying records"+(first+1)+"-"+(first+itemsPerPage min count)+" of "+count)
calculates to
"Displaying records 1-0 of 0"
Does not look right to me, I would expect "Displaying records 0-0 of 0"
b) I'd suggest to split calculations away from
Text("Displaying records "+(first+1)+"-"+(first+itemsPerPage min count)+" of "+count)
so that it could be used via paginate() binding like
<nav:recordsFrom /> - <nav:recordsTo /> of <nav:recordsCount />
c) Calculation for "next" link [2]
"next" -> pageXml(first+itemsPerPage min itemsPerPage*(numPages-1), nextXml),
calculates negative value when 'numPages' is zero resulting
"next"-link to contain
?offset=-<itemsPerPage>
Expected: No link in case of empty collection (as there is for "prev")
d) Same problem for the "last" (as for "next", described previously)
e) More of a debatable robustness issue: I would expect the Paginator
offered by the framework to be smart enough that it could not result
in an error like
Message: org.postgresql.util.PSQLException: ERROR: OFFSET must
not be negative
(even when user plays with parameters on address bar)
[1] Line 102 at
http://github.com/lift/lift/blob/2.x-2.8_devel/framework/lift-base/lift-webkit/src/main/scala/net/liftweb/http/Paginator.scala
[2] Line 142 at
http://github.com/lift/lift/blob/2.x-2.8_devel/framework/lift-base/lift-webkit/src/main/scala/net/liftweb/http/Paginator.scala
Original thread: http://groups.google.com/group/liftweb/browse_thread/thread/50260536cebd0ae
Initially assigned to 'timperrett' because instructed so by 'dpp':
> Finally, Tim Perrett currently maintains the paginator. He's off-grid this week.
> [...] Tim will address the ticket when he has the bandwidth.
Leave a comment
on 2010-08-06 15:21 *
By dchenbecker
Assigned to set to dchenbecker
Status changed from New to Accepted
I'll work on this with Naftoli
on 2010-08-11 10:18 *
By dchenbecker
Related association with ticket #616 was added
Pulled Naftoli's changes into a new branch. Tested in my local app and set up a new review request:
http://reviewboard.liftweb.net/r/419/
http://reviewboard.liftweb.net/r/419/
on 2010-08-16 13:33 *
By dchenbecker
Tested fine and RB passed, so committed to 2.x-2.7_devel and 2.x-2.8_devel, but master is failing with a seemingly unrelated error. Holding ticket open until I can get that resolved.
(In revision:5b643a5a2f11d6043714aac0e8156a2d7f06ee5c) Fix Paginator display count and negative offset bug
Closes #611
Fixes several issues with paginator index and offset handling
and display.
Branch: master
Closes #611
Fixes several issues with paginator index and offset handling
and display.
Branch: master