Two Laptop Bag*
The moose likes Struts and the fly likes which is the best option to validate if an ActionForm has changed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "which is the best option to validate if an ActionForm has changed?" Watch "which is the best option to validate if an ActionForm has changed?" New topic
Author

which is the best option to validate if an ActionForm has changed?

facundo martin rodriguez
Greenhorn

Joined: Aug 05, 2010
Posts: 3
which is the best option to validate if an ActionForm has changed (the user changed one or more values in it inputs on the jsp) in Struts?

the ActionForm has a lot of instance variables, including lists.


Facundo Rodriguez
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Maybe a hash code, if you don't need to know *what* changed?
facundo martin rodriguez
Greenhorn

Joined: Aug 05, 2010
Posts: 3
David Newton wrote:Maybe a hash code, if you don't need to know *what* changed?


your solution is very promising, but, i can't deal with the collisions of the hascode(), i haven't the 2 ActionForm's instance in the same time to applie the equal() method if i have a collisions with the hascode ( when i tell you collisions i refer to have the same hascode but with diferents values in the intance variables of the ActionForm's intances).
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Pass the original hashcode in the form submission.

If you're hashing correctly the chances of a collision are *extremely* small.
facundo martin rodriguez
Greenhorn

Joined: Aug 05, 2010
Posts: 3
David Newton wrote:Pass the original hashcode in the form submission.

If you're hashing correctly the chances of a collision are *extremely* small.



Hi David,

Thanks for your interest.

I don't have the code of the hasCode redefinition, i didn't do it yet. But my idea is get all the hashcode of the differents intance variables of the ActionForm and multiply that by a fix number (may be 13) and then add all .

May be something like that



that is my ActionForm:



I can't allow any chance of collition, it is a core funcionality of the application.
 
GeeCON Prague 2014
 
subject: which is the best option to validate if an ActionForm has changed?