Struts array of text boxes with same name

30 views
Skip to first unread message

Arvind Chandok

unread,
Jan 1, 2008, 5:33:37 AM1/1/08
to technical-...@googlegroups.com

Hi all,
 
Can anybody tell me how can i create a array of text boxes with <html:text tag.
 
Like in simple html
 
<input type="text" name="item[]">
<input type="text" name="item[]">
 
Like this we can create but using struts tags how can i create and how can i manage  it in form beans
 
 
 
Thanks
--
Arvind Chandok
Contact : 9899825712

Rajnish Kamboj

unread,
Jan 2, 2008, 11:53:39 PM1/2/08
to technical-...@googlegroups.com
Hello Arvind

I do not much about Struts... Just wait for others to reply on the same elegantly

Below is some stuff i have found on net.. if it could help you
---------------------------------------------------------------------------------------

When you use the struts-html tags, give each property
a subscript.  For example
  <html:text property="myField[0]" name="myForm"/>
  <html:text property="myField[1]" name="myForm"/>
  <html:text property="myField[2]" name="myForm"/>

In your form class, implement get and set methods that
also take an index.  For example
  public void setMyField( int index, String value )
  {
    ...
  }
  public String getMyField( int index )
  {
    ...
  }

The biggest benefit to using this struts feature, is
that it lets you work with a dynamic number of fields
on a page.  You can certainly put the <html:text> tag
inside a loop to create many fields in the output.

Also refer to .. : http://www.ajug.org/archive/ajug-members/10303/msg00022.html
-
Regards
Rajnish kamboj
--
Rajnish kamboj
Mob: +91-9971692473

[ Smile a lot, it costs nothing :) ]

Arvind Chandok

unread,
Jan 3, 2008, 8:32:12 AM1/3/08
to technical-...@googlegroups.com
Thanks Rajnish
Reply all
Reply to author
Forward
0 new messages