Wednesday, July 28, 2010

Accessing appName property from controller in Grails

It is trivial to access the appName property from within the config.groovy file, and it is a common practice to do so. Here is an example of specifying an external config file based on the name of the grails application:

grails.config.locations = ["file:$userHome/.osaas/$appName.groovy"


I could find no where obvious that described how to access this appName property from a constructor. You would expect the following to work but it does not:

grailsApplication.config.appName


The following does work however

grailsApplication.metadata['app.name']

2 comments:

  1. Thanks a lot... :) I have been searching a lot to figure this out!

    ReplyDelete