Grails pagination with url base

In Grails if you deside to customize url links it’ll break pagination on generated by scaffolding list view.
For example, I need url with prefix and built-in parameter defined like this:


By default tag <g:paginate/> creates link like this:


And there is no way to provide prefix or base for url.

How to fix.
Let’s create custom tag with ability to pass base for generated url.
Take a look to source code of <g:paginate/> tag and copy it’s code to your taglib, find the line where linkTagAttrs variable is define:

def linkTagAttrs = [action: action]

and add after this definition lines:

 if (attrs.base) {
            linkTagAttrs.base = attrs.base

That’s it!
Now your pagination tag generates correct links with prefix and you can use it like this:

<myTags:paginate total="${categoryInstanceTotal}" base="${request.contextPath}/data/${params.venueName}"/>

P.S.: The fix for  <g:sortableColumn> is the same. (=