Is there a way to create an array that is both gettable and settable from any controller in a grails project? Any ideas are appreciated!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you say “gettable and settable” do you mean you want any controller to be able to modify the individual elements of the array or that you want a controller to be able to completely replace the array with another array and have the change visible to other controllers?
The “Grails way” would be to encapsulate the array within a service and access it through that, with the service handling whatever synchronization is required to keep things consistent – and you will definitely need synchronization of some kind if you have data that is potentially being mutated by several threads concurrently. Or store the data in your database and let that handle the transactional updates.
To give a more specific answer I’d need to know what use case(s) this shared array is intended to support.