How to use session in domain class in grails -


this question has answer here:

i want store loggedinuser in table. accessing loggedinuser using session.but getting error no such property session class. how use session in domain?

class genderaudit {       string name     user doneby      def genderaudit(gender gender,string operation)     {         this.name=gender.name         this.doneby = session.loggedinuser      } } 

domain classes shouldn't know http layer. set value service or controller has access data.

also, note defining constructor fine, have define no-arg constructor hibernate since creates new empty instances , calls setters. in general don't use parameterized constructors in grails since map constructor added groovy convenient.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -