开发者

Grails: How to edit GSP (views/show) to show desired info

I have two Domain classes (Drives & Computer)

class Computer {

    static hasMany = [drives:Drive]
    String computerName

    static constraints = {
    computerName(nullable:false)
    }
}


class Drive {

    static belongsTo = Computer
    Computer computerName

    static constraints = {
    computerName(nullable:false)
    }
}

Wh开发者_高级运维en the application is run and the DriveController is clicked, the drop menu for Computer Name shows something like: computer: 1

My desired output is what I actually have entered for the computer: 1 which in my instance was Owner987

I have generated my views and believe I need to edit a g.link, perhaps in show.gsp of Drive.

All help is appreciated.


By default it will show the toString() output, so override that to show what you want:

class Computer {

    static hasMany = [drives:Drive]
    String computerName

    String toString() { computerName }
}

Also note that properties are not-null by default so you can omit the nullable:false constraints in both classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜