Link to home
Start Free TrialLog in
Avatar of appari
appariFlag for India

asked on

Struts and dynamic controls/control array

I am new to struts framework.

the working environment is windows + IIS + Tomcat 5 + Struts 1.1

the problem is i need to develop a jsp page using struts framework and the view is something like this

|----------------------------------------------------------------------------------|
|        ID        |                     |      Name       |          Qty    |    Stock     |
|----------------------------------------------------------------------------------|
| TextBox       |       Button     |   TextBox       |   TextBox     |  TextBox   |
|----------------------------------------------------------------------------------|
|TextBox       |       Button     |   TextBox       |   TextBox     |  TextBox   |
|----------------------------------------------------------------------------------|
|TextBox       |       Button     |   TextBox       |   TextBox     |  TextBox   |
|----------------------------------------------------------------------------------|
|TextBox       |       Button     |   TextBox       |   TextBox     |  TextBox   |
|----------------------------------------------------------------------------------|
|TextBox       |       Button     |   TextBox       |   TextBox     |  TextBox   |
|----------------------------------------------------------------------------------|

"TextBox" means HTML Text box is displayed same with button.
in asp/jsp i can name the controls dynamically and use request.getparameter("controlName") to get the value.

but how do i do the same thing using struts frame work? here in the above sample i displayed only 4 rows but in actual case it can be 10/20. is there any way achieving this? i am a newbie to using Struts, please give me step by step example on creating actionform and actionclass.
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of appari

ASKER

i got my problem solved using dynaactionform and using the method described in the following article.
http://www.developer.com/java/ejb/article.php/2233591


still i am intrested if it is possible to do the same using actionform instead of dynaactionform.
TimYates: can you please explain how do i control how many rows i want to display using the method you posted? and what are the entries in struts-config.xml? and can you post a sample for actionclass.
> can you please explain how do i control how many rows i want to display using the method you posted?

When you create the array of Row objects, only add the number you want to display...

> and what are the entries in struts-config.xml?

You will need a start action that fills in the array of Rows, and an Action as usual to catch the values when the form is posted...

> and can you post a sample for actionclass.

It's the same as any normal action...