Grails: how to set data binding to use load method instead of get one? -


if have form such bellow

<input type="text" name="somecollection[0].someassociation.id"/> <input type="text" name="somecollection[1].someassociation.id"/> <input type="text" name="somecollection[2].someassociation.id"/> 

because grails provides automatic data binding when encounters .id suffix, seems grails uses get method instead of load 1 implies 3 queries follows

select * someassociationclass id = ? select * someassociationclass id = ? select * someassociationclass id = ? 

i need load method because not hit database unless use other getid() (not applied). so, how can customize data binding uses load method ?

you can use command object bind data when submit form.

@validateable class exampleco { string username // here field name use on view ,both name same in domain class. static constraints = { username nullable: false     // here can provide same constraints define in domain classes. check validation on field here.    } } 

in can write vale this.

 <g:form action="saveskills" method="post">` <g:textfield name="name" id="skillname" class="skillname" value="${exampleco?.username}"                                  placeholder="add skill" style="width: 280px"/> </g:form> 

when fill form , hit action save it.name of field same name in command object. in action can receive in command object this,

def actionname(exampleco exampleco){   domainclass domainclass = new domainclass()   binddata(domainclass,exampleco)  domainclass.save()  } 

hope help, if understand question well.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -