Cannot get property 'constraints' on null object with embedded domain

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot get property 'constraints' on null object with embedded domain

alphajin
I have two domain class:

class Property {
        String propertyNo
        String propertyTitle
        String propertyDescription
        Date modifyDate
        String propertyType
        String street
        String city
        String state
        boolean isSold
        String postalCode
        boolean isPriceNegotiable
        PropertyPrice propertyPrice = new PropertyPrice()

        static embedded = ['propertyPrice']
       
        static constraints = {
                propertyNo()
                propertyType()
                propertyTitle()
                propertyDescription()
                street()
                city()
                state()
                postalCode()
                modifyDate(display:false)
                isSold(display:false)
    }
       
        def beforeInsert = {
                modifyDate = new Date()
        }
       
        def beforeUpdate = {
                modifyDate = new Date()
        }
       
        def String toString(){
                return propertyNo
        }
}

and the other one is
class PropertyPrice {
        String priceType
        String priceValue
       
    static constraints = {
                priceType(inList:["SOLD","RENT","BOND"])
    }
}

When I create property, it always throw NullPointException.
Caused by GrailsTagException: Error executing tag <g:form>: Error executing tag <g:render>: Error evaluating expression [propertyPriceInstance.constraints.price
Type.inList] on line [83]: Cannot get property 'constraints' on null object
->>   36 | doCall    in D:/workspace/ssproperty/grails-app/views/property/create.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Caused by GrailsTagException: Error executing tag <g:render>: Error evaluating expression [propertyPriceInstance.constraints.priceType.inList] on line [83]: Can
not get property 'constraints' on null object
->>   31 | doCall    in D:/workspace/ssproperty/grails-app/views/property/create.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Caused by GroovyPagesException: Error evaluating expression [propertyPriceInstance.constraints.priceType.inList] on line [83]: Cannot get property 'constraints'
 on null object
->>   83 | run       in D:/workspace/ssproperty/grails-app/views/property/_form.gsp

Could you tell me what's wrong with my code?  My grails version is 2.0.3

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Cannot get property 'constraints' on null object with embedded domain

bendoerr
Looks like you might be using view scaffolding. My guess is that the view scaffolding doesn't support the embedded object.

-Ben
Reply | Threaded
Open this post in threaded view
|

Re: Cannot get property 'constraints' on null object with embedded domain

alphajin
I am not sure what is view scaffolding. Could you please explain it in details?

Thanks!