Pass value from grails controller to a class inside src/groovy -


i have grails application. want use value grails controller class (say mycontroller) inside class in src/groovy/myclass.groovy

how can pass value grails controller class class? couldn't find relevant.

i tried this:

class mycontroller { def name = "myapp" }  class myclass{ def username = mycontroller.name } 

please correct me . thanks

it hard sure without knowing doing want pass value argument method in myclass , don't want value field in controller class.

class mycontroller {     def somecontrolleraction() {         def name = // don't know                    // getting value, got somewhere          def mc = new myclass()         mc.somemethod(name)         // ...     } }  class myclass {     def somemethod(string name) {         // whatever want name     } } 

or pass value constructor argument:

class mycontroller {     def somecontrolleraction() {         def name = // don't know                    // getting value, got somewhere          def mc = new myclass(name: name)         // ...     } }  class myclass {     def name } 

i hope helps.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -