Grails indexed parameters

前端 未结 4 1222
悲&欢浪女
悲&欢浪女 2020-12-28 10:10

I have a list of Team objects that have an Integer seed property. I want to edit all the teams\' seeds at once, in a single form. I\'m sure

4条回答
  •  别那么骄傲
    2020-12-28 11:05

    params is more than a regular Map, it's a GrailsParameterMap that automatically builds up sub-Map structures based on splitting the parameter names by '.'. You might take advantage of this by using the following gsp:

    
     
       
       
      
     
    
    

    NB: there's no [] in the name attributes. The controller is now pretty simple using some black Grails magic :

    log.error "params = ${params}"
    params.teams.findAll {k,v -> !k.contains(".")}.each { k,v ->
           bindData(Team.get(v.id), v)
    }
    

    The first operation findAll filters out all parameters with a dot inside. The rest is a map of maps holding the row id in k and the id and seed in v.

    I hope this answers your question.

提交回复
热议问题