Grails 2.4.x comes with support for HAL.
Despite some problems with embedded resources (https://jira.grails.org/browse/GRAILS-10954) i'm starting to make it works. However still i am not sure how to deal with pagination links ("prev", "next") as they are shown in the documentation.
Is there any way HalJsonRenderer can help with this point?
What i've done is extend HalJsonCollectionRenderer and overwrite this method:
protected void writeLinkForCurrentPath(RenderContext context, MimeType mimeType, JsonWriter writer) {
final href = linkGenerator.link(uri: context.resourcePath, method: HttpMethod.GET.toString(), absolute: absoluteLinks)
final resourceRef = href
final locale = context.locale
def link = new Link(RELATIONSHIP_SELF, href)
link.title = getResourceTitle(resourceRef, locale)
link.contentType = mimeType ? mimeType.name : null
writeLink(link, locale, writer)
}
Adding links for PREV and NEXT to get rendered when required.
In order to do this we need access querystring params that can be accessed as arguments in the RenderContext object (context.getArguments())
It works quite well and is not too complex.
However if ther is another way i will be happy to know.