Grails 3 - f:table - 如何显示相关 class 的 属性

Grails 3 - f:table - how to display property of related class

有2个简单的类:

class Entity{
Integer id
Status status
String type
}

class Status{
Integer id
String name
}

我只需要替换实体列表中 "status" 字段的表示并编辑 - 而不是 my.appStage : 1 -> "normal" 怎么做?

在以下目录中创建名为 _displayWrapper.gsp 的文件:

/views/entity/status

然后在文件中添加以下内容:

${value.name}

假设您只想打印文本 'normal'。

还有其他方法可以实现此目的,请参阅 docs

问题后更新:

对于f:all,您可以将_wrapper.gsp添加到上述目录并添加以下内容:

<div class="fieldcontain required">
    <label for="status">Status</label>
    <g:select name="status" from="${Status.all}" optionValue="name" optionKey="id" value="${entity?.status}"/>
</div>