grails unknown number of model objects in the view -


working in grails 2.2

i have situation need able handle unknown number of committeemembers in view. these need both created , displayed.

each 1 has usual attributes - name, address, contact information, userid.

i understand if name form fields same name, grails return collection me iterate over. in case, however, faced situation:

cm_firstname

cm_lastname

cm_address

cm_email

cm_userid

so mean given collections of each of these fields? not useful there no way corelate various firstnames correct lastnames, etc.

i enjoying grails , looking forward feedback.

i'll tell do, may or may not best option. because don't data binding.

for case example, name fields: "cm.firstname, cm.lastname, cm.address, cm.email, cm.userid".

if in service:

grailswebrequest webutils = webutils.retrievegrailswebrequest()  list committeemembers = [].withdefault {new grailsparametermap([:], webutils.getcurrentrequest())} 

in controller:

list committeemembers = [].withdefault {new grailsparametermap([:], request)} 

then

params.cm.each { k, v ->     if (v instanceof string[]) {         v.eachwithindex { val, idx ->             committeemembers[idx]."$k" = val         }     }     else {         committeemembers[0]."$k" = v     } } 

then can do:

committeemembers.each {     <create it.firstname, it.lastname, etc> } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -