guys! I`d like to make 'clever pagination'. For example, if i already have params.category=Auto - i want it to be added to my params. Of course, i can do smth like this :
<g:paginate total="${total}" 开发者_开发百科max="10" maxsteps="5" params="[category: params.category,subcategory: params.subcategory]"/>
But if current params.subcategory is null - it will also be added to url ( ?subcategory=&category=Auto) . I don`t want to have 'subcategory=' in my params in such a case! Also I can do it with string concatenations to create new url - but maybe grails have some cheats/mechanism to create new url without string concatenations?
Cheers, Dmitry.
There aren't any great solutions I can think of. You could try:
params="${[category: params.category,subcategory: params.subcategory].findAll {it.value} }"
Alternatively, provide your own custom tag that strips out null param values before delegating to the paginate tag.
精彩评论