aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dynamic row in STRUTS2" Watch "dynamic row in STRUTS2" New topic
Author

dynamic row in STRUTS2

dheenathayalan sivam
Greenhorn

Joined: Nov 03, 2008
Posts: 2
dear,

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
Greenhorn

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 ).


 
Don't get me started about those stupid light bulbs.
 
subject: dynamic row in STRUTS2