I am fairly new to Grails, and I would like to understand how to parse some form "params" with a controller, using a counter variable as an index?
I have a form:
<g:form controller="config" action="parseReports">
<div>
<g:each in="${allReports.toList()}" var="each" >
<g:hiddenField name="reportName${allReports.indexOf(each)}" value="${each}" />
</g:each>
<g:hiddenField name="reportCountSize" value="${allReports.size()}" />
...
With some hidden variables.
In the controller, I have:
def reportCount = params.reportCountSize.toInteger()`
def reportCount0 = params.reportCount0.name.toString()`
This works fine.
I would like to know how to use a loop / index:
for (counter in 0..reportCount) {`
def myReport = "${params}.reportCount${counter}.name.toString()}"`
....
I cannot find out how to get myReport to get the form value of params.reportCount0.name.toString(), but use the ${counter} variable?
Any help would be appreciated.
Thanks
Miles.