I have a situation. I want to set one value to some parameter in Config.groovy in my Grails project. This parameter should have different value for each environment, i.e. for dev environment it is like abc = "devValue", for test environment like abc="testValue" and for production environment like abc="prodValue". and then I want to set that value as a hidden field value on gsp page according to running environment.
how to set value in Config.groovy and get different value for same parameter according to environment on gsp in Grails?
462 Views Asked by Jigar Patel At
2
There are 2 best solutions below
0
Jigar Patel
On
Thanks Igor Artamonov,
I found the solution below.
I added code below in Config.groovy
environments {
development {
abc="devValue"
}
test {
abc="testValue"
}
production {
abc="prodValue"
}
}
And then in gsp i set the hidden field as below.
<input id="oid" type="hidden" name="oid" value="${grailsApplication.config.abc}">
Thank you.
Related Questions in GRAILS
- No such property: id for class: java.lang.String
- Using like to non-string columns in Grails
- How to convert object reference that are in string form to that refrence class object?
- Restrict access to java-melody monitoring url
- Intercepting springsecurity behavior in grails
- Sort a Grails Domain list using a column index instead of column name
- Using service beans and dependency Injection in Geb Functional Tests
- how to create a pdf editor for grails
- Remove method of the List is not working
- Grails query based on Date
- Unit tests fail to run after upgrade from grails 2.3 to 2.5
- GGTS Classpath won't recognize folder on classpath after gradle eclipse
- Grails 2.4.4. hierarchical domain structure: find
- change input field value via javascript in grails
- Create skinny War file using Maven in Mavenized Grails
Related Questions in GROOVY
- spring-integration-dsl-groovy-http return null when i use httpGet method
- groovy xml namespace definition used in attribute value lost after XmlParse/serialize
- jenkins with groovy postbuild .Not able to execute anything in groovy script field
- How can I set the the expected Exception type for a catch statement with a parameter I've passed into a method?
- How to add quotes into sql where clause in Groovy script?
- integrating groovy with api
- java.util.ConcurrentModificationException on cloneEntity
- jenkins (or groovy) using pom.xml from previous execution
- How to use multiple classes in multiple files in scripts?
- How to work around Groovy's XmlSlurper refusing to parse HTML due to DOCTYPE and DTD restrictions?
- Workaround for lack of generators/yield keyword in Groovy
- Groovy's @CompileStatic and map constructors
- Java syntax to Groovy syntax
- Groovy TimeDuration Argument Types
- Elasticsearch : _score always 0 in Groovy script
Related Questions in GSP
- how to create a pdf editor for grails
- GSP in plain Spring MVC - AST Transformation is not applied to taglib
- Grails retrieve controller parameters in g:each
- showing null point exception when findAllBy - for session object
- Execute controller function in Grails via Ajax
- Grails: Carry forward params on g:actionSubmit is clicked
- Grails Asset Pipeline: URLs with cache digest in file name within static assets
- Update icon returned by CSS
- how to call variable from config.groovy
- Modify table in gsp from controller
- Break in g:if / g:each
- Clear POST/GET request, Grails, GSP
- how to retrive attached file saved in database in grails platform, and mongoDb database
- Not able to get multiple Canvas Pie Charts
- grails checking first radio button
Related Questions in GRAILS-CONFIG
- How to access grailsApplication and ApplicationContext in Functional Tests
- Grails 2.0 use configuration value from external file in POGO
- Bean definition using Grails Spring DSL needs index/type/name arguments
- Grails UserCredentialsDataSourceAdapter configuration issue
- how to get version 4.0 of httpclient off of my classpath in grails
- CSS in vaadin plugin for grails
- How to map all requests to a controller go to one method and access the original parameter
- Grails URL Mappings using name for multiple adress
- How to define properties of a Service Bean from application.yml in Grails 3?
- Could I override the grails.env during runtime
- how to set value in Config.groovy and get different value for same parameter according to environment on gsp in Grails?
- Is it possible to reference variables defined in different configuration files in grails?
- How to tell Grails application which environment it is in?
- Use of 'grails.logging.jul.usebridge' in grails config.groovy
- Is it possible to load more config files from an externalized config file in Grails?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There's already an example of this in the
Config.groovythat's generated for you:so you can just add your setting there: