Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Determing if Form Data Changed

 
Joe Brigs
Ranch Hand
Posts: 70
IBM DB2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Form with 30 input fields. The form is intitally populated with Data from a Database and user can update one field or 30.. When the update occurs I have to write one record for every field that the user changed ( Nice DB design , I had no part in it ) Is there a easy way to determine which field was updated ? Or do I have to compare each field in my Servlet to figure this out. ( I use to code in CICS (mainframe) and when we needed to determine if a field changed we would check an attribute flag thats why I asked this question)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comparing to the original to see what's changed is the first thing that comes to mind. There is no innate concept of 'changed field' in HTTP.
 
Anuj Batra
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use javascript to do this.

on lost focus event of form input fields you can check if the input value is changed.
if yes then set a hidden prameter the specifies the value whether yes or no
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a problematic approach as it wil false positive fields that are set back to their original value. If that's not an issue it is one way to approach it but I generally would rather explicitly deal with this on the server rather than implicitly on the client.
 
Paul Clapham
Sheriff
Posts: 21142
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I recall right, the CICS environment would have had the same possibility of false-positives. However I agree that the straight-forward method of comparing the data sent to the browser with the data coming back from the browser is a good way to go.
 
Ashish Kataria
Greenhorn
Posts: 14
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem lies in not to check if each entry has been changed, but rather, in adding a record for each changed record. If the comparison is not done properly, you might end up in adding records for attribute whose values haven't changed(which is a major back end bug).
And as explained by the marshal..this is the first thing that comes to mind.
I would suggest you to go with the tried and tested traditional way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic