tinny
2010-03-08 03:26:03 UTC
Im stuck in a recursive loop on this one and I just need a gentle push in the
right direction please.
I have a list type page that's collection of elements to be displayed is
built using GORM's criteria builder.
E.g.
def criteria = Connection.createCriteria()
def connectionTypes = [ConnectionType.ELECTRICITY, ConnectionType.GAS]
...
def connectionInstanceList = criteria {
and {
if(params.referenceNumber && params.referenceNumber != '') {
like("referenceNumber", params.referenceNumber)
}
if(params.customerFirstName && params.customerFirstName != '') {
like("customerFirstName", params.customerFirstName)
}
if(params.customerSurname && params.customerSurname != '') {
like("customerSurname", params.customerSurname)
}
if(params.siteAddress && params.siteAddress != '') {
like("streetAddress", params.siteAddress)
}
if(params.initiator && params.initiator != '') {
initiator {
like("businessName", params.initiator)
}
}
'in'("type", connectionTypes)
firstResult(params.offset)
maxResults(params.max)
}
}
I would obviously like to use the g:paginate tag to page through all of the
possible results. The only thing I cant figure out right now is how to get
the total count for this query (not limited with "firstResult" and
"maxResults") in a clean way. I mean I could cut and paste 90% of the above
query and insert a rowCount projection or something like that, but it just
feels wrong to have to perform these two slightly different queries twice
just to get a total count.
What do you think? Any feedback welcome.
Thanks
right direction please.
I have a list type page that's collection of elements to be displayed is
built using GORM's criteria builder.
E.g.
def criteria = Connection.createCriteria()
def connectionTypes = [ConnectionType.ELECTRICITY, ConnectionType.GAS]
...
def connectionInstanceList = criteria {
and {
if(params.referenceNumber && params.referenceNumber != '') {
like("referenceNumber", params.referenceNumber)
}
if(params.customerFirstName && params.customerFirstName != '') {
like("customerFirstName", params.customerFirstName)
}
if(params.customerSurname && params.customerSurname != '') {
like("customerSurname", params.customerSurname)
}
if(params.siteAddress && params.siteAddress != '') {
like("streetAddress", params.siteAddress)
}
if(params.initiator && params.initiator != '') {
initiator {
like("businessName", params.initiator)
}
}
'in'("type", connectionTypes)
firstResult(params.offset)
maxResults(params.max)
}
}
I would obviously like to use the g:paginate tag to page through all of the
possible results. The only thing I cant figure out right now is how to get
the total count for this query (not limited with "firstResult" and
"maxResults") in a clean way. I mean I could cut and paste 90% of the above
query and insert a rowCount projection or something like that, but it just
feels wrong to have to perform these two slightly different queries twice
just to get a total count.
What do you think? Any feedback welcome.
Thanks
--
View this message in context: http://n4.nabble.com/GORM-criteria-pagination-headache-tp1584073p1584073.html
Sent from the Grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
View this message in context: http://n4.nabble.com/GORM-criteria-pagination-headache-tp1584073p1584073.html
Sent from the Grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email