This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic row in STRUTS2

 
dheenathayalan sivam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ).


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic