select list displayed with authrority not with id role in grails -


i have 2 class role , user package tachemanagement.secu

class role {

string authority  static hasmany = [users: user] static mapping = {     cache true }  static constraints = {      authority(nullable:true)  } 

} package tachemanagement.secu

class user {

transient springsecurityservice static belongsto = [rol: role]   string username string password boolean enabled = true boolean accountexpired boolean accountlocked boolean passwordexpired   static transients = ['springsecurityservice']  static constraints = {     username blank: false, unique: true     password blank: false }  static mapping = {     password column: '`password`' }  set<role> getauthorities() {     userrole.findallbyuser(this).collect { it.role } set }  def beforeinsert() {     encodepassword() } protected void encodepassword() {     password = springsecurityservice.encodepassword(password) }  def beforeupdate() {     if (isdirty('password')) {         encodepassword()     } } 

}

*

i want display select list role in user form

but list displayed name of id role (1,2,3) haw can displayed authority not id ?

use tostring() method in role following

class role{      string authority      static hasmany = [users: user]     static mapping = {           cache true     }      static constraints = {            authority(nullable:true)      }     string tostring() {          "$authority"     } } 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -