Grails one-to-many databinding with dynamic forms -


i'm using grails 2.3.5 , try persist multiple domains coming dynamic form.

to achieve this, used approach lazy lists described in: http://omarello.com/2010/08/grails-one-to-many-dynamic-forms/

the forms genereated , neccessary parameters in params-map, binding list not work.

i read lot topic last 2 days , found answers on stackoverflow, think these methods work older grails versions.

to illustrate problem, code:

house.groovy

class house {  ....attributes removed minimize example   list<adress> adresses = [].withlazydefault { new adress() } // list adresses = listutils.lazylist(new arraylist<adress>,factoryutils.instantiatefactory(adress.class));  static hasmany = [adresses:adress]         //def getadresses(){       //return lazylist.decorate(adresses, factoryutils.instantiatefactory(adress.class))       //}     static mapping = {     adresses cascade:"all-delete-orphan" } 

template dynamic forms --> created correctly

<div id="adress${i}" class="adresses-div" style="<g:if test="${hidden}">display:none;</g:if>margin-bottom:10px; "> <g:hiddenfield name='adresses[${i}].id' value='${adresses?.id}'/> <g:hiddenfield name='adresses[${i}].deleted' value='false'/> <g:hiddenfield name='adresses[${i}].neu' value="${adresses?.id == null?'true':'false'}"/>  <g:textfield name='adresses[${i}].street' value='${adresses?.street}' /> <g:textfield name='adresses[${i}].land' value='${adresses?.land}' />      <span class="del-adresses">     <img src="${resource(dir:'images/skin', file:'database_delete.png')}"          style="vertical-align:middle;"/> </span> 

housecontroller - edit action

houseinstance.properties = params 

so, form templates created correctly , the input values existent in parameter map.

my problem databinding multiple adresses created 1 form. according example project provided link above, parameter binding should automatically create new adress-objects , save them childs house.

when debugging application can see there right parameters seems list cannot create new adress-object.

the 'adresses' list, contains null value after binding--> [null]

like mentioned above, tried few solutions problem, couldn't resolve it. lazylist approach not supported in grails 2.3.5 , works older version.

i hope had same same problem , can give me hint

thanks in advance

i have experience same problem. refer this: grails 2.3 one-to-many databinding dynamic forms

try remove id: in params if it's new phone. tested grails 2.3.11 , using in project.

here changed in _phone.gsp

<div id="phone${i}" class="phone-div" <g:if test="${hidden}">style="display:none;"</g:if>>      <g:if test="${phone?.id != null}">            <g:hiddenfield name='phones[${i}].id' value='${phone?.id}'/>      </g:if>      ... </div> 

thanks @hakuna1811


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -