You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by vinodh r <vi...@yahoo.com> on 2010/10/09 16:59:52 UTC

Create Text Box Dynamically

Hi,
I want to create 'n' text box dynamically, the 'n' should comes from database Whether 'n' should be 3 or 4 or 12 it will be vary dynamically and decided by the end user.


Is it possible to create 'n' text Box dynamically or at run time with struts2, Also how text box can be accessed because i don't know the name! suppose I want to access a specific text box?


Thanks,Vinodh


      

Re: Create Text Box Dynamically

Posted by Dave Newton <da...@gmail.com>.
Better to use a Collection, but may not matter much.

Also, if order needs to be guaranteed, use index notation (square
brackets along with an index). If you need to add the text boxes
dynamically (via JavaScript) just create DOM elements that match the
HTML generated by the S2 tags.

Dave

On Saturday, October 9, 2010, Li Ying <li...@gmail.com> wrote:
> Hi
>
> I think you can use tags looks like this:
>
> <s:iterator var="counter" begin="1" end="{n}" >
>   <s:textfield name="data" />
> </s:iterator>
>
> to generate 'n' text box dynamically.
>
> The html code should be:
> <input type="text" name="data">
> repeats 'n' times.
>
> When user input text in these text boxes and
> submit the form, the request should
> include several parameters which has the
> same name "data" and the different value.
>
> I think the Action class should have
> a property named [data] (same as the name of input tag),
> and the data type of this property should be
> array of String, so it can hold all the value input
> in the text boxes.
>
>
> 2010/10/9 vinodh r <vi...@yahoo.com>:
>> Hi,
>> I want to create 'n' text box dynamically, the 'n' should comes from database Whether 'n' should be 3 or 4 or 12 it will be vary dynamically and decided by the end user.
>>
>>
>> Is it possible to create 'n' text Box dynamically or at run time with struts2, Also how text box can be accessed because i don't know the name! suppose I want to access a specific text box?
>>
>>
>> Thanks,Vinodh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Create Text Box Dynamically

Posted by Li Ying <li...@gmail.com>.
Hi

I think you can use tags looks like this:

<s:iterator var="counter" begin="1" end="{n}" >
  <s:textfield name="data" />
</s:iterator>

to generate 'n' text box dynamically.

The html code should be:
<input type="text" name="data">
repeats 'n' times.

When user input text in these text boxes and
submit the form, the request should
include several parameters which has the
same name "data" and the different value.

I think the Action class should have
a property named [data] (same as the name of input tag),
and the data type of this property should be
array of String, so it can hold all the value input
in the text boxes.


2010/10/9 vinodh r <vi...@yahoo.com>:
> Hi,
> I want to create 'n' text box dynamically, the 'n' should comes from database Whether 'n' should be 3 or 4 or 12 it will be vary dynamically and decided by the end user.
>
>
> Is it possible to create 'n' text Box dynamically or at run time with struts2, Also how text box can be accessed because i don't know the name! suppose I want to access a specific text box?
>
>
> Thanks,Vinodh

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org