This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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