Quantcast

Value of textfield from params

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Value of textfield from params

bhushan154
Hi All,

I am generating textFields from a list of questions

For loop:
<g:each var="${question}" in="${review.questions}">

Generating textField and assigned the id to the name so I can save many questions at once on the controller.
<g:select from="['','Yes','No']" name="questionResponse_${question.id}" class="span2" value="${question.response ?: ''}"  />

I want to set the value of the select list from the params object.
So I would like to do something like
value=${params.questionResponse_${question.id} ?: question.response}

How do I go about doing this? Can anybody help me out with this? I would really appreciate it.

Thank you
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Value of textfield from params

sergiomichels
Not sure if is that what you want but params[' questionResponse_ '+question.id] works?


On Mon, Jun 11, 2012 at 6:50 AM, bhushan154 <[hidden email]> wrote:
Hi All,

I am generating textFields from a list of questions

For loop:
<g:each var="${question}" in="${review.questions}">

Generating textField and assigned the id to the name so I can save many
questions at once on the controller.
<g:select from="['','Yes','No']" name="questionResponse_${question.id}"
class="span2" value="${question.response ?: ''}"  />

I want to set the value of the select list from the params object.
So I would like to do something like
value=${params.questionResponse_${question.id} ?: question.response}

How do I go about doing this? Can anybody help me out with this? I would
really appreciate it.

Thank you

--
View this message in context: http://grails.1312388.n4.nabble.com/Value-of-textfield-from-params-tp4629877.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Lok
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Value of textfield from params

Lok
This post has NOT been accepted by the mailing list yet.
params["questionResponse_ "+question.id]  works for me in different scenarios. this is a right way to go when your parameter key is dynamic.

thanks
Lok
Cheers, Lok
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Value of textfield from params

bhushan154
In reply to this post by sergiomichels
Sergio and Lok,

Thanks a lot for your replies.

<g:checkBox name="documentationType_${document.id}" value="${params['documentationType_'+document.id]}"/> 

Did it for me :)
Loading...