robfletcher / grails-angular-scaffolding

A Grails plugin for scaffolding views using Angular.js
http://grails-ng.cloudfoundry.com/
87 stars 43 forks source link

ng-generate-all and ng-generate-all fail when generating for create. #37

Open amexboy opened 9 years ago

amexboy commented 9 years ago

ng-generate-* generate the htmls for list and show and throw a NullPointerException when proccessing create.

This is the exception that is thrown

java.lang.NullPointerException: Cannot get property 'matches' on null object
    at SimpleTemplateScript12.renderStringEditor(SimpleTemplateScript12.groovy:64)
    at SimpleTemplateScript12.this$4$renderStringEditor(SimpleTemplateScript12.groovy)
    at SimpleTemplateScript12$this$4$renderStringEditor.callCurrent(Unknown Source)
    at SimpleTemplateScript12.run(SimpleTemplateScript12.groovy:19)
    at grails.plugin.angularscaffolding.AngularTemplateGenerator$_closure1.doCall(AngularTemplateGenerator.groovy:41)
    at SimpleTemplateScript11.renderFieldForProperty(SimpleTemplateScript11.groovy:50)
    at SimpleTemplateScript11.renderFieldForProperty(SimpleTemplateScript11.groovy)
    at SimpleTemplateScript11.this$4$renderFieldForProperty(SimpleTemplateScript11.groovy)
    at SimpleTemplateScript11$this$4$renderFieldForProperty.callCurrent(Unknown Source)
    at SimpleTemplateScript11.run(SimpleTemplateScript11.groovy:32)
    at grails.plugin.angularscaffolding.AngularTemplateGenerator.generateView(AngularTemplateGenerator.groovy:75)
    at grails.plugin.angularscaffolding.AngularTemplateGenerator$_generateView_closure3.doCall(AngularTemplateGenerator.groovy:88)
    at grails.plugin.angularscaffolding.AngularTemplateGenerator.generateView(AngularTemplateGenerator.groovy:87)
    at grails.plugin.angularscaffolding.AngularTemplateGenerator.generateViews(AngularTemplateGenerator.groovy:50)
    at _NgGenerate_groovy.generateForDomainClass(_NgGenerate_groovy:43)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at _NgGenerate_groovy$_run_closure1.doCall(_NgGenerate_groovy:25)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at NgGenerateViews$_run_closure1.doCall(NgGenerateViews:10)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
    at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)

I did some digging and i reached at a conclusion, that this is occurring on line 64 of renderEditor file

 private String renderStringEditor(domainClass, property, name) {
        def sb = new StringBuilder()
        sb << '<input type="text"'
        sb << ' id="' << name << '"'
        sb << ' name="' << name << '"'
        sb << ' data-ng-model="item.' << name << '"'
        if (cp.matches) sb << ' pattern="' << cp.matches << '"'
        if (isRequired()) sb << ' required'
        sb << '>'
        sb as String
    }
//I could't find where cp was declared
amexboy commented 9 years ago

Fixed this issue already! https://github.com/robfletcher/grails-angular-scaffolding/pull/38