How to access Grails "session" from Groovy POGO? -
i have grails 2.3.6 app , wondering scope of session variable is? available, natively, groovy class located under grails-app? if not, have particular groovy source:
myapp/grails-app/widgets/com/me/myorg/fizzbuzz.groovy
how create current session object available fizzbuzz, within fizzbuzz method can write:
class fizzbuzz { def dosomething() { session.foo = "true" } }
you can't create session available arbitrary pogo or pojo, shouldn't anyway. have options. interaction fizzbuzz traces have access session , thing pass session downwards phone call stack makes way fizzbuzz instance method argument or go other way , have fizzbuzz homecoming , contain info needs set in session.
you hacky requestcontextholder.currentrequestattributes().getsession(), or meta programme method onto fizzbuzz in fizzbuzz class refer session. don't think recommend that. made work fact trying access web stuff straight pogos hint flow isn't organized way should be.
if elaborate little more on doing help offer more specific solutions.
session grails
No comments:
Post a Comment