This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Struts and the fly likes dynamic row in STRUTS2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dynamic row in STRUTS2" Watch "dynamic row in STRUTS2" New topic

dynamic row in STRUTS2

dheenathayalan sivam

Joined: Nov 03, 2008
Posts: 2

Help needed for updating an list in jsp with values added as dynamic row in STRUTS2.

I have a table displaying data from list. It displays 2 rows. I have a button which on clicks added one more row.. blank row.. in which data is added. now on submit, i need to update list.

Any help would be much appreciated!
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I'm assuming you are adding this row on the client side using javascript. If thats the case the trick is to make sure to give your new input fields the correct name attribute. They'll need to the same names as the input fields in the other rows of the table except there will be an index that will need to be incremented on the new rows. Easiest way to do this may be to look at the name attributes of the input fields in the html source for the existing rows to try to mimic them.
dheenathayalan sivam

Joined: Nov 03, 2008
Posts: 2
tnx friend.,

i got the result.

instead of using <s:textfield name="textFields[0]" />, i have replaced for (within JS method)

<input type='text' name='locationId[" + num + "]' value='' id='dyamicRowAction_locationId_" + num + "_'/>

(its actual replacement html tag for S2 tag - get it from view source ).

jQuery in Action, 3rd edition
subject: dynamic row in STRUTS2
It's not a secret anymore!