Question

Currently we are upgrading Grails version from 1.3.3 to 2.2.4. While doing so, we encountered a Boolean binding problem for a check-box value.

Here is the code...

Domoan: 
    A {
         :
         :
         Boolean check
      }
View: 
              :
              :
          <g:checkbox name = "check" value = &{A?.Check}/>

Controller:
   def Save {
           def aInstance = new A(params)
           if (aInstance.check)
           }  

In the above case the Boolean values are not binding properly and we are always getting "null" in the if statement.

Any idea how we could overcome this issue?

Thanks for your time.

Was it helpful?

Solution

After Many net surfing I got the point. Acctualay it was problem of transient value bind problem.

Now Statically typed instance properties are bindable by default. Properties which are not bindable by default are those related to transient fields, dynamically typed properties and static properties.

so solution is:

The bindable constraint must be assigned a literal boolean value. Dynamic expressions are not valid values for the bindable constraint. The value must be the literal true or false.

In my issue:

Domoan:

A {
     :
     :
     Boolean check
     static transients = ['check']
     static constraints = {
       check bindable: true
       :
       : 
     }

}

source: http://grails.org/doc/latest/ref/Constraints/bindable.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top