You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Subhani Shaik <ss...@gmail.com> on 2007/08/31 08:25:00 UTC
How to give a text field name dynamically?
Hi,
I have the following code...
<table>
<struts2:iterator value="Questions">
<tr>
<td>Question <struts2:property value="questionID" /><struts2:property
value="route" /></td>
</tr>
<tr>
<td>
<!-- How to give dynamic name to this text box? This answer is needed
in next pages. -->
<struts2:textfield id="THIS NAME SHOULD BE DYNAMIC. I WANT THIS TO BE
'questionID' VALUE" tooltip="Please enter text here." >
</struts2:textfield>
</td>
</tr>
</struts2:iterator>
</table>
Here, 'Questions' is a class that contains 'questionID' as a field. And this
returns 'List' over here. When i am iterating i'll get single item from the
list. And my textfield name should be as the value of questionID (this is
the key).
I want something like this...
<struts2:textfield id="Qn1"/>
<struts2:textfield id="Qn2"/>
<struts2:textfield id="Qn3"/>
... so on
Regards,
Subhani.
--
View this message in context: http://www.nabble.com/How-to-give-a-text-field-name-dynamically--tf4358482.html#a12421314
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to give a text field name dynamically?
Posted by Pooja Kaur <po...@gmail.com>.
Try this:
<table>
<% int i= 1;
%>
<struts2:iterator value="Questions">
<% String propertyName = "Qn"+i;
i++;
%>
<tr>
<td>Question <struts2:property value="questionID"
/><struts2:property
value="route" /></td>
</tr>
<tr>
<td>
<!-- How to give dynamic name to this text box? This answer is
needed
in next pages. -->
<struts2:textfield id="<%=propertyName%>" tooltip="Please enter text
here." >
</struts2:textfield>
</td>
</tr>
</struts2:iterator>
</table>
Thanks
On 8/31/07, Subhani Shaik <ss...@gmail.com> wrote:
>
>
> Hi,
>
> I have the following code...
>
> <table>
> <struts2:iterator value="Questions">
> <tr>
> <td>Question <struts2:property value="questionID"
> /><struts2:property
> value="route" /></td>
> </tr>
> <tr>
> <td>
> <!-- How to give dynamic name to this text box? This answer is
> needed
> in next pages. -->
> <struts2:textfield id="THIS NAME SHOULD BE DYNAMIC. I WANT THIS TO
> BE
> 'questionID' VALUE" tooltip="Please enter text here." >
> </struts2:textfield>
> </td>
> </tr>
> </struts2:iterator>
> </table>
>
> Here, 'Questions' is a class that contains 'questionID' as a field. And
> this
> returns 'List' over here. When i am iterating i'll get single item from
> the
> list. And my textfield name should be as the value of questionID (this is
> the key).
>
> I want something like this...
>
> <struts2:textfield id="Qn1"/>
> <struts2:textfield id="Qn2"/>
> <struts2:textfield id="Qn3"/>
> ... so on
>
>
> Regards,
> Subhani.
> --
> View this message in context:
> http://www.nabble.com/How-to-give-a-text-field-name-dynamically--tf4358482.html#a12421314
> Sent from the Struts - User mailing list archive at Nabble.com<http://nabble.com/>
> .
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: How to give a text field name dynamically?
Posted by Subhani Shaik <ss...@gmail.com>.
Thanks Nuwan.
It's working.
--
View this message in context: http://www.nabble.com/How-to-give-a-text-field-name-dynamically--tf4358482.html#a12460663
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to give a text field name dynamically?
Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,
try something like this and see
<table>
<struts2:iterator value="Questions" status="status">
<tr>
<td>Question <struts2:property value="questionID" /><struts2:property
value="route" /></td>
</tr>
<tr>
<td>
<struts2:textfield id="${status.index}" tooltip="Please enter text here." >
</struts2:textfield>
</td>
</tr>
</struts2:iterator>
</table>
Thanks,
Nuwan
Subhani Shaik wrote:u
> Hi,
>
> I have the following code...
>
> <table>
> <struts2:iterator value="Questions">
> <tr>
> <td>Question <struts2:property value="questionID" /><struts2:property
> value="route" /></td>
> </tr>
> <tr>
> <td>
> <!-- How to give dynamic name to this text box? This answer is needed
> in next pages. -->
> <struts2:textfield id="THIS NAME SHOULD BE DYNAMIC. I WANT THIS TO BE
> 'questionID' VALUE" tooltip="Please enter text here." >
> </struts2:textfield>
> </td>
> </tr>
> </struts2:iterator>
> </table>
>
> Here, 'Questions' is a class that contains 'questionID' as a field. And this
> returns 'List' over here. When i am iterating i'll get single item from the
> list. And my textfield name should be as the value of questionID (this is
> the key).
>
> I want something like this...
>
> <struts2:textfield id="Qn1"/>
> <struts2:textfield id="Qn2"/>
> <struts2:textfield id="Qn3"/>
> ... so on
>
>
> Regards,
> Subhani.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org