Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.3.7
-
Fix Version/s: 2.3-M1
-
Component/s: Controllers, TagLib
Description
When creating an object that has a hasMany property, this propery will only be set using a "g:select" tag with "multiple" attribute set to true. Grails should not discriminate which DOM object allows binding to hasMany relationships. If a list of id's are sent as params to a controller and the corresponding domain object has a field that is a Collection, the binding should occur no matter if the list was sent from a multi-select box or a custom tag that also sends a list of id's.
Background: I wrote a custom tag for multi-selection using checkboxes instead of a multi-select list (from a UI perspective, it only makes more sense). When submitting, I notice that the corresponding Set in my domain object is always null. When I change from my custom tag to "g:select" w/ "multiple" set to true, the corresponding Set in my domain has all the correct values. Both my tag and the g:select tab send the same list, but the only noticeable differences are
1) g:select sends a multiple flag and my checkboxes cannot do that
2) g:select does not send hidden fields, checkboxes send hidden fields, and the hidden fields are not populated (seperate bug??)
binding success when using g:select w/ multiple
<org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap@dd83d83 request=org.apache.catalina.core.ApplicationHttpRequest@72f106b0 nestedDateMap=[:] wrappedMap=[lastName:, enabled:on, location.id:1, location:[id:1], approver.id:null, approver:[id:null], locale:null, _outOfOffice:, create:Create, password:, username:, password2:, email:, roles:[1, 2, 3], _enabled:, firstName:, action:save, controller:agent]>
<customerrelationsdesk.Agent@3914c2fe username= password= firstName= lastName= email=null locale=null lastPasswordChange=null approver=null location=location 1 enabled=true outOfOffice=false id=null version=null roles=[admin, temp, readonly] agencies=null approvals=null>
binding fails when using custom checkBoxList
<org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap@39e97abb request=org.apache.catalina.core.ApplicationHttpRequest@42fb636b nestedDateMap=[:] wrappedMap=[lastName:, enabled:on, location.id:1, location:[id:1], approver.id:null, approver:[id:null], locale:null, _outOfOffice:, password:, create:Create, username:j, password2:, email:, roles:[1, 2, 3], _roles:[, , ], _enabled:, firstName:, action:save, controller:agent]>
<customerrelationsdesk.Agent@4aa53726 username=j password= firstName= lastName= email=null locale=null lastPasswordChange=null approver=null location=location 1 enabled=true outOfOffice=false id=null version=null roles=null agencies=null approvals=null>