I need to capture all the changes made by the user(screen level) and save the old/new value to the DB for auditing purpose.I have an implementation for audit trail in my application as stated below.I would like to know whether my implementation is correct or it can be implemented in a better way.
For all the components(text,textarea,combo etc) used in the application i have included an attribute say "defaultText" which holds the initial value of the component on load of the page.For this i have included the variable "defaultText" in the FTL file for each component.On submitting the form i create a JSON string by comparing old value to the new value and send it to the server.An interceptor intercepts all CRUD action calls which parse the JSON string and inserts it to the corresponding table if the action is successful.I am using struts2.Please let me know your valuable suggestions.Thank you.
Martin James wrote:I would like to know whether my implementation is correct or it can be implemented in a better way.
That really isn't what we do here. You can browse our FAQ HowToAskQuestionsOnJavaRanch to get a better feel for what that is.
My personal rule of thumb is that something "works and can be seen to work", that is, it is well-tested, doesn't have bugs and can be understood by someone reasonably intelligent reading the code and comments.