Grails

checkBox does not work for nested boolean properties

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.0.2, 1.0.3
  • Fix Version/s: 1.3.5
  • Component/s: TagLib
  • Labels:
    None

Description

This is related to bug 2486.

This change broke the ability to handle nested boolean properties. For instance, to extend that example, if you did <g:checkBox name="book.author.isFamous" and then bindData(book, params['book']) the params come in as "book.author._isFamous". In order for this example to work, it needs to be "book._author.isFamous".

For now I am using a custom tag that allows a "base" attribute to determine where to put the _.

<sf:checkBox name="book.author.isFamous" base="book"> => book._author.isFamous.

Then when base is left off it puts the underscore before the entire property name. I think that makes more sense but it is a breaking change.

Open to other workarounds as well.

  1. patch_for_GRAILS-3299.patch
    26/Mar/10 7:22 AM
    4 kB
    Jens Lukowski

Issue Links

Activity

Hide
Chris Denman added a comment -

I concur, this issue still exists in 1.2.0.

I have attached an application that shows the problem. Run the application and browse to http://127.0.0.1:8080/GrailsNestedBinding.

There are two pages that correspond to two actions on the same controller and domain instances. They both update a nested boolean property, viz. parent.children[0].visible. After the update action we redirect to the same page so that the boolean status can be seen conveniently.

I hope this helps.

Show
Chris Denman added a comment - I concur, this issue still exists in 1.2.0. I have attached an application that shows the problem. Run the application and browse to http://127.0.0.1:8080/GrailsNestedBinding. There are two pages that correspond to two actions on the same controller and domain instances. They both update a nested boolean property, viz. parent.children[0].visible. After the update action we redirect to the same page so that the boolean status can be seen conveniently. I hope this helps.
Hide
Jens Lukowski added a comment -

Here's a patch for the current git version of grails-core which provides an implementation and tests for a base attribute for the checkBox tag.
The checkBox tag now inserts the _ after the base. If you use base="." the _ is appended to the start. If no base is specified the current default behaviour is used.

Show
Jens Lukowski added a comment - Here's a patch for the current git version of grails-core which provides an implementation and tests for a base attribute for the checkBox tag. The checkBox tag now inserts the _ after the base. If you use base="." the _ is appended to the start. If no base is specified the current default behaviour is used.
Hide
James Cook added a comment -

I'm pretty sure this bug was fixed in this build (1.3.1-SNAPSHOT):
http://hudson.grails.org/job/grails_core_gradle_build/144/
So it can now be closed

Show
James Cook added a comment - I'm pretty sure this bug was fixed in this build (1.3.1-SNAPSHOT): http://hudson.grails.org/job/grails_core_gradle_build/144/ So it can now be closed
Hide
Fedor Smirnoff added a comment -

Bug is in 1.3.3 as well

Show
Fedor Smirnoff added a comment - Bug is in 1.3.3 as well
Hide
Graeme Rocher added a comment -

This issue appears to duplicate GRAILS-6224

Show
Graeme Rocher added a comment - This issue appears to duplicate GRAILS-6224
Hide
Joshua Moore added a comment -

This issue seems to be back in 1.3.7.
e.g.
{{<g:checkBox name="book.author.famous" value="${bookInstance?.author?.famous}" />}}
renders
_book.author.famous
for the name of the hidden field instead of
book.author._famous

Show
Joshua Moore added a comment - This issue seems to be back in 1.3.7. e.g. {{<g:checkBox name="book.author.famous" value="${bookInstance?.author?.famous}" />}} renders _book.author.famous for the name of the hidden field instead of book.author._famous

People

Vote (7)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: