wood burning stoves*
The moose likes Struts and the fly likes How to detect the beans that are changed on form? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to detect the beans that are changed on form?" Watch "How to detect the beans that are changed on form?" New topic
Author

How to detect the beans that are changed on form?

Amit Athavale
Greenhorn

Joined: Mar 31, 2003
Posts: 29
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to detect the beans that are changed on form?
 
Similar Threads
Dynamically increased form (Collection)
Preview Page before Submission
JavaScript DataStructures
mutiple record validate
Question related to logic:iterate tag