Grails - 传递hasOne关系形成

时间:2016-04-12 15:04:16

标签: grails gorm gsp

我有2个豆子:

class GroupVisitReconfirmation {
  int visitorsNumber
  static belongsTo = [
    groupVisitRequest: GroupVisitRequest
  ]
  static constraints = {
      visitorsNumber nullable: false, validator: { val, obj, errors ->
          def visitorsNumber = obj.groupVisitRequest.visitorsNumber
      }
  }
}

class GroupVisitRequest extends VisitRequest {
  static hasOne = [
    groupVisitReconfirmation: GroupVisitReconfirmation
  ]
}

我也有这样的形式用于GroupVisitReconfirmation:

<g:form action="completeReconfirmation" params="${params.frame ? [frame: '✓'] : [:]}" novalidate="novalidate">
  <fieldset class="form">
    <field:wrapper bean="${bean}" field="visitorsNumber">
      <g:render template="reconfirmation/textField"  />
    </field:wrapper>
  </fieldset>
</g:form>

我如何传递此形式的GroupVisitRequest?因为当我现在这样做时,我在约束中有Null Pointer Exception。

0 个答案:

没有答案