I have got a solution to the problem:
How to add dynamic textboxes to a Struts jsp page that uses DynaActionForm:
I have used indexed property with multiple submit buttons.
In DynaActionForm, I have used a
String[] named userName[] with size of 1.
But, I change the size dynamically in the Action class.
I have added the textboxes dynamically using a scriptlet tag, based on value of counter which is set in Action class and saved in the request object of execute method of Action class.
I have set the scope of Action as session in struts-config.xml file.
There are three submit buttons, one each for adding a textbox, removing a text box and submitting the form. Each submit button has a name and a value associated with it.
Name of submit button is taken as a <form-property-> with type java.lang.String in DynaActionForm.
The value associated with the submit button's property is set automatically and is compared in the Action class to check which submit button is pressed and to execute code accordingly.
<<<<<<<<<<It will get confusing if I keep explaining like this.><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<It is simpler than it sounds.><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<So I am attaching the program which I made using Eclipse Helios and Struts 1.1><<<<<<<<<<<<
<<<<<<<<<<In my code,
Robin is a valid userName><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<It does not add another textbox unless you type something in previous one><<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<
Sorry guys, zipped folders are not allowed on this website<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<
I have uploaded it at this url: Dynamic TextBox using Struts 1.1 and Eclipse Helios
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Sorry guys, this website asks to create an account to download but it is free and I found no better option <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Please watch that the zipped file
'myStruts1.zip' gets downloaded automatically without prompting once you create account on
"keepandshare.com">
<<<
I have shared the document publicly, so I hope that you can download it even without creating account<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<