2014-10-08 107 views
1

我怎樣才能從格姆視圖中隱藏password柱: enter image description hereGrails的腳手架隱藏表列

我的域類:

class SecUser { 
    static scaffold = true 

    transient springSecurityService 

    String username 
    String password 


    boolean enabled = true 
    boolean accountExpired 
    boolean accountLocked 
    boolean passwordExpired 



    static transients = ['springSecurityService'] 

    static constraints = { 

     username blank: false, unique: true 
     password (display:false, blank: false) 



    } 

    static mapping = { 
     password column: '`password`' 
    } 

    Set<SecRole> getAuthorities() { 
     SecUserSecRole.findAllBySecUser(this).collect { it.secRole } as Set 
    } 

    def beforeInsert() { 
     encodePassword() 
    } 

    def beforeUpdate() { 
    if (isDirty('password')) { 
      encodePassword() 
     } 
} 

    protected void encodePassword() { 
     password = springSecurityService.encodePassword(password) 
     // password = password 
    } 
} 
+0

爲什麼你在域類中有'static scaffold = true'? – 2014-10-08 15:33:29

+0

這是一個例子。如果我刪除它,它不能解決我的問題 – lsv 2014-10-08 15:45:47

+0

我不希望刪除它會解決問題。通常情況下,除非您的應用程序(或您的應用程序使用的插件)中具有該屬性的代碼,否則該屬性在域類中將毫無意義。我認爲默認腳手架插件可以識別控制器中的屬性。 – 2014-10-08 15:48:08

回答

2

display: false約束用來隱藏從默認腳手架查看屬性。 https://github.com/jeffbrown/scaffolddisplay的項目演示了這一點。你必須在你的應用中有一些阻礙。可能您已經生成了包含該屬性的視圖。可能你正在使用提供視圖的插件。