Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to detect the beans that are changed on form?

 
Amit Athavale
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using nested tag to display almost 50 rows to user. Each row (bean) has 5 fields. When user submit the form, I want to send to backend only the collection of beans that r changed. I do not want to send all 50 rows, when only 5 rows are send.

One way to do this is save the Old collection of beans on action form, and then when user submit the form, check for changed rows and put changed rows in the result collection to send to backend.

Is there any other smarter way to do this? I feel this is a common problem, when the design asks to send collection of objects to save to DB. Hence was wondering, if there is any smarter way... any tag support or any pattern to handle this scenario?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34378
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit,
You could use JavaScript to indicate when a row is changed. However this is less reliable than making the copy. So the solution you described is the best one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic