grails - pass a string to grailsApplication.config in service layer -
can know how pass string parameter grailsapplication.config.
have tried following. class configpropertiesloader { def grailsapplication def getproperty(string property ){ def properties=grailsapplication.config.${property} homecoming properties; }
this error got,
error 2013-02-13 12:59:29,850 [http-bio-8080-exec-10] error 0].[grails] - servlet.service() servlet grails threw exception message: cannot property 'config' on null object line | method ->> 30 | getproperty in com.nagra.ms.sam.config.configpropertiesloader$$enxjabt5 | 51 | <init> in com.nagra.ms.sam.entity.account.controller.accountcontroller | 196 | getbean . . . . in grails.plugin.cache.web.filter.abstractfilter | 842 | lookupcontroller in grails.plugin.cache.web.filter.pagefragmentcachingfilter | 176 | dofilter . . . . in '' | 63 | dofilter in grails.plugin.cache.web.filter.abstractfilter | 1110 | runworker . . . in java.util.concurrent.threadpoolexecutor | 603 | run in java.util.concurrent.threadpoolexecutor$worker ^ 722 | run . . . . . . in java.lang.thread
i not sure understand exact question going list couple different scenarios solution:
consider next 2 entries in config.groovy
feedbackaddress="xyz@abcdefg.com" blogs = {groupname-> if(groupname == 'it') { //return blog urls folks } else if(groupname == 'ux') { //return blog urls ux folks } else { //return others } }
case 1: using string config name. can access feedbackaddress like:
def feedbackaddress = grailsapplication.config["feedbackaddress"]
case 2: passing paramater config. can list blogs specific grouping like:
def groupname = "it" grailsapplication.config.blogs(groupname) //this give whatever's defined in block of config.
hope helps..
grails properties
No comments:
Post a Comment