【问题标题】:Custom fields displayed by Grails Fields plugin with <f:display>Grails Fields 插件使用 <f:display> 显示的自定义字段
【发布时间】:2018-02-28 18:36:30
【问题描述】:

我想使用 Grails Fields 插件的&lt;f:display&gt; 标签显示一些字段。我尝试了以下方法:

<f:display bean="user" property="authorities" label="roles"/>
<f:display bean="user" property="username"/>

但是,这只会显示字段值,而不是标签。我尝试添加自定义模板grails-app/views/_fields/default/_displayWrapper.gsp

<span id="${property}-label" class="property-label">${label}</span>
<div class="property-value" aria-labelledby="${property}-label">${value}</div>

此自定义模板

一起使用
<f:table collection="${userList}" except="password"/>

但是当我使用&lt;f:display&gt;时它被忽略了

【问题讨论】:

    标签: grails gsp


    【解决方案1】:

    在您的_displayWrapper 中,您应该使用${widget} 而不是${value},因为您希望_displayWidget 的渲染获得特定类型的渲染。

    &lt;f:table&gt; 是 IMO 有点坏,但我会尽快调查。我正在 Greach 做一个关于 Fields 插件的演示,所以我需要做点什么:-)

    【讨论】:

    • 在我的代码中查看我所做的字段插件演示示例:github.com/sbglasius/g3-fields-plugin-demo
    • 我正在尝试做一些类似的事情:使用 显示除 id、dateCreated 和 lastUpdated 之外的所有字段。我需要找到一种方法来显示 id 和 dateCreated。 except="[]" 和类似的似乎在 f:display 上不起作用,但是 f:table 确实允许你显示 ID 等。我原以为能够在 display 上显示 id 比在 table 上更重要?我正在尝试找到一种在其他字段中显示 ID 的方法。还没有运气。
    • 目前这是一个限制。我建议你在 github 上提出增强请求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多