Grails脚手架,仍然无法以编辑形式处理java8 localdateTime,也无法执行Map属性

时间:2019-02-01 14:43:04

标签: grails scaffolding localdate

我正在使用Grails v3.3.9,build.gradle中的最新grails hibernate 8和grails插件,以及java8插件,fields插件(没有任何区别)和Hibernate 8。

compile "org.hibernate:hibernate-core:5.1.5.Final"
compile group: 'org.hibernate', name: 'hibernate-java8', version: '5.1.5.Final'
compile "org.grails.plugins:gsp"
compile 'org.grails.plugins:grails-java8:1.2.3'  //java 8 features including datetime in GSP
compile 'org.grails.plugins:fields:2.2.10'

我已经在我的Domain模型上尝试过这个模型,该模型使用LocalDateTime扩展了一个抽象类

abstract class Agreement {

    String contractReference
    String status
    LocalDateTime contractSignedDate
    LocalDateTime lastUpdated   //updated by framework
    LocalDateTime dateCreated   //updated by framework

    static constraints = {
        contractReference nullable:false
        status nullable:false
        contractSignedDate nullable:true
    }
}

和这里的具体课程

class MaintenanceAgreement extends Agreement {

    String level
    Map category = [:]  //p1 to p5 and sla details 

    //static belongsTo = [serviceProvider : OrgRoleInstance, maintainer: OrgRoleInstance]

    // implemented as unidirectional many to one !  mag point to org
    static belongsTo = [maintainer: OrgRoleInstance]

    static constraints = {
        level nullable:false
        //serviceProvider nullable:true
        maintainer nullable:false   //ref to maintainer party

        category nullable:false
    }
}

如果我在Db中有一个带有空列的引导程序中的记录,则grails不会为空条目提供任何字段持有者。返回引导程序并手动创建一个值,然后重新启动。

至少此时间列表和显示渲染将实际值显示在表单上

enter image description here

但是,当您创建一个新表单(或编辑动作)时,您会得到此信息。 contractSigned(localDateTime)没有编辑器,最后,领域模型具有作为Map的属性类别,并且Map列没有没有编辑器

enter image description here

这是一个真正的问题。我可以回到尝试使用Date的地步,但这确实是倒退的一步,该平台建议支持新的数据时间格式。在“地图”列中考虑一下我可能会遇到的后退情况。

我在这里错过了一些可以做到这一点的东西吗?还是我重新提出缺陷?

我在之前的3.3.8版本中也遇到了这个问题,也没有解决数据时间问题的问题

previous record

另请参见以前的功能介绍

make java new dates first class citizen in grails

1 个答案:

答案 0 :(得分:0)

请勿在您的课程中使用<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script> <script src="https://unpkg.com/angular-mocks@1.7.6/angular-mocks.js"></script> <div id="root"> <div ng-controller="appController"></div> </div>作为数据类型。您可能无法对其进行编辑。请改用LocalDateTime类型。然后grails本身将为您提供日期选择器以进行添加和编辑。如果您需要在GSP中提取当前日期时间,则可以使用Date作为该字段的值。