Pagination links with a locale prefix in URLs Grails -
if you're using language prefix in url mappings such as
/$lang/$controller/$action?/$id?   and urls generating contain parameters in addition lang parameter, you'll following url, additional param such offset:
/book/list?offset=10&lang=en   but breaks mappings. instead, want url this:
/en/book/list?offset=10   how can achieve that?
create following bean (assuming lang param called "lang"):
class langawareurlmappingsholderfactorybean extends urlmappingsholderfactorybean {      @override     public urlmappingsholder getobject() throws exception {         def obj = super.object         obj.default_controller_params = [urlmapping.controller, urlmapping.action,     "lang"] set         obj     }    }   and adjust resources.groovy:
"org.grails.internal.url_mappings_holder"(langawareurlmappingsholderfactorybean) { bean ->     bean.lazyinit = true }   and you'll get
/en/book/list?offset=10   instead of
/book/list?offset=10&lang=en      
Comments
Post a Comment