• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically adding rows to JSP

 
nagesh siddu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am looking for a logic/ idea/ code snippet that can help in the following scenario

I am using struts 1.2 and tomcat web server.

I have a JSP which has two buttons, ADD and SAVE.
I need to display a row with three Textboxes with the first text box pre-populating a value from database (some thing like sequence number). The user enters the remaining two boxes.

When I press the ADD button a new row is to be displayed with the three textboxes, the first textbox gets a value from the data base. When I press SAVE, the form is to be submitted completely with the data filled by user and the generated sequence numbers.

What I am now trying:
I have an ArrayList kept in the request scope in the previous action. This array list has only one Value Object with three parameters and their getter/setter methods. I am using <logic: iterate >tag in my current JSP to iterate over the array list. It is properly showing one row. In my second action I have a switch case to identify that ADD button was pressed and I am getting the ArrayList from session object. Here I am adding a new Value Object to the list, and setting it again in session scope.

I t is displaying properly that is a new row is added when ever I press the add button.
Things are fine so far.

The problem:
1.When I press refresh(browser) button, it is still adding a new row.
2.I could not get he ArrayList from the form object.
Can any one point to some references/ examples similar to this?
Note: Sorry I posted this on a wrong forum earlier. I am aware of the rules.
Regards,
Nagesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic