views:

34

answers:

1

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.

+1  A: 

Struts doesn't have a form validation that determines changes.

You can try and keep a previous form in a session and do a comparison between the previous action form and the current form.

The Elite Gentleman
is a good option, but if the user click on cancel button, the form object with all it values, will remain in session
Facundor
If the user clicked cancel, the current form (which is on the request) will be blanked and removed. So check if the form won't exist on request and then take the form stored in session.
The Elite Gentleman
you refer to put in the jsp, something like this when the user click "cancel".<%=request.getSession().removeAttribute("myForm")%>
Facundor
Nope, when you click cancelled, the response is returned to your struts action. You will use your struts action, `isCancelled(request)` which returns a boolean value to check whether your form was cancelled. If it is, then go to your session and retrieve the form, populate your ActionForm to the one stored on the session.
The Elite Gentleman
thank you very much Gentleman! your info helped me a lot
Facundor
Glad to have helped....but you need to tick the checkbox underneath the score to accept that this answer worked.
The Elite Gentleman