【发布时间】:2016-11-24 12:36:10
【问题描述】:
场景:带有传递字段的订单显示视图,总成本。默认字段生成视图不会呈现传递字段,因此我必须手动指定要查看的字段。以下工作正常:
<f:with bean="customerOrder">
<f:display property='token' wrapper="displayText"/>
<f:display property='lineItems' wrapper="displayCollection"/>
<f:display property='total' wrapper="displayMoney"/>
<f:display property='dateCreated' wrapper="displayDate"/>
<f:display property='customer' wrapper="displayLink"/>
</f:with>
displayCollection 部分由 views/_fields/displayCollection/ 内的 _displayWrapper.gsp 文件处理,如下所示:
<li class="fieldcontain" style="list-style-type: none;">
<span class="property-label">${label}</span>
<span class="property-value" aria-labelledby="${property}-label">
<ul>
<g:each in="${value}" var="item">
<li>${item?.toString()}</li>
</g:each>
</ul>
</span>
</li>
这是一个通用的集合显示字段。它适用于购物车中的文章、用户发布的帖子等。唯一的是,集合成员仅显示为文本,而不是链接。
如果 ${value} 是单个类成员而不是集合,则下面的 _displayWrapper.gsp 可以正常工作。
<li class="fieldcontain" style="list-style-type: none;">
<span class="property-label">${label}</span>
<span class="property-value" aria-labelledby="${property}-label">
<g:link action="show" controller="${property}" id="${value?.id}">${value?.toString()}</g:link>
</span>
</li>
问题是,我如何从集合的成员中获取控制器名称,而集合是通过 ${value} 获得的?
我已经安装了视图模板,但没有运气。同样,我查看了字段插件代码,也没有运气。
有什么想法吗?
【问题讨论】: