I’m having trouble accessing springSecurityService from resources.groovy file, I’m trying to load user locale setting and create LocaleResolver
import User
beans = {
localeResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) {
def user = User.get(springSecurityService.principal.id)
if (user?.settings?.locale) {
defaultLocale = new Locale(user?.settings?.locale)
java.util.Locale.setDefault(defaultLocale)
}
}
}
Thanks,
Mika
Your code above doesn’t make a lot of sense. In
resources.groovyyou’re supposed to define the implementation class of Spring beans and set their dependencies. It looks like you’re trying to actually write the implementation class inresources.groovy.Instead you should write your own
LocaleResolverclassThen in
resources.groovy, define a bean of this type that replaces the defaultlocaleResolverbean