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

How to understand form fields were changed to new values

 
Diggy Lans
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Junilu Lacar
Bartender
Posts: 7482
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic