How to understand form fields were changed to new values
posted 12 years ago
Hello! I display some data from a database to a user. The data lives in an ActionForm. A user may change the data and in this case I want to save it to the DB. But I am looking for a way not to save data if nothing was changed. Is there a way to do it with Struts? thanks in advance
Not in Struts per se but you can do it with POJOs (Plain Old Java Objects) and overriding the equals() method. Basically, you put all new values in one instance, then see if it equals() another instance that has the old values. This JavaWorld article talks about how to override equals().