Fields Plugin - Grails表

时间:2016-04-05 04:44:30

标签: grails scaffold

我使用grails的字段插件并遇到问题,当我使用字符串List作为属性类搭建一个域类时,显示为 org.grails.datastore.mapping.dirty.checking.DirtyCheckingList

List view

这是我的域类

class Role {
 String id
 String role
 List<String> permissions

static constraints = {
 }
}

在其他视图中也会显示为Show,

Show view

我想自定义模板以显示表格和节目视图中的权限列表,但我没有找到有关如何使用f:all标签和f:table标签自定义模板的信息/ p>

这是索引页

<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main" />
    <g:set var="entityName" value="${message(code: 'role.label', default: 'Role')}" />
    <title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>
    <a href="#list-role" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
    <div class="nav" role="navigation">
        <ul>
            <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
            <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
        </ul>
    </div>
    <div id="list-role" class="content scaffold-list" role="main">
        <h1><g:message code="default.list.label" args="[entityName]" /></h1>
        <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
    </g:if>
    <f:table collection="${roleList}" />

    <div class="pagination">
        <g:paginate total="${roleCount ?: 0}" />
    </div>
</div>
</body>
</html>

显示页面

<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main" />
    <g:set var="entityName" value="${message(code: 'role.label', default: 'Role')}" />
    <title><g:message code="default.show.label" args="[entityName]" /></title>
</head>
<body>
    <a href="#show-role" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
    <div class="nav" role="navigation">
        <ul>
            <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
            <li><g:link class="list" action="index"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
            <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
        </ul>
    </div>
    <div id="show-role" class="content scaffold-show" role="main">
        <h1><g:message code="default.show.label" args="[entityName]" /></h1>
        <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
    </g:if>
    <f:display bean="role" />
        <g:each var="permission" in="${role.permissions}">
        <li>${permission}</li>
        </g:each>
<g:form resource="${this.role}" method="DELETE">
<fieldset class="buttons">
    <g:link class="edit" action="edit" resource="${this.role}"><g:message code="default.button.edit.label" default="Edit" /></g:link>
    <input class="delete" type="submit" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
</fieldset>
</g:form>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

Fields插件提供了<f:table><f:all>标记。您可以在此处找到相关文档(这将很快从Grails文档链接)http://grails-fields-plugin.github.io/grails-fields/guide/introduction.html

您可能需要自定义脚手架模板以支持您正在做的事情 - 我不确定Fields插件是否支持不属于hasMany的List属性。您可以通过生成模板(将它们添加到项目中)来自定义模板,如下所示:https://grails.github.io/grails-doc/latest/ref/Command%20Line/install-templates.html