aspose file tools*
The moose likes Struts and the fly likes Identify Form field changes in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Identify Form field changes in Struts" Watch "Identify Form field changes in Struts" New topic
Author

Identify Form field changes in Struts

Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
I would like to identify which form fields(properties) has been changed during form submit in struts.

Here is the situation:

I have a Struts form which has set of fields and this form is used to edit. On submit I would like to know if a particular field say "server IP" field in the form has been changed or not. Is there any predefined of identifying that in struts.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

No, not anything particular I know. But why you need it, can't you just UPDATE all the fields without bothering if the value is really changed or not.

OR If you've some requirement like the user is not allowed to change any field, then make it DISABLE, then.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
Well, I am doing so for other fields but this field change would require an additional step which i want to trigger/execute only when this field changes to avoid the overheads.

I am sure struts would have some option to identify whether a particular form field has changed or not during form submit.

I know its not straight forward, but any help would be appricated.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Shriram Gopalakrishnan wrote:Well, I am doing so for other fields but this field change would require an additional step which i want to trigger/execute only when this field changes to avoid the overheads.

OK, if you have some set of fields which you want to look for any value change, then I suggests using "hidden" fields for those desired properties, so that when form gets submitted, in server side, you can compare submitted TEXT FORM field with the original unchanged HIDDEN fields.
Shriram Gopalakrishnan wrote:I am sure struts would have some option to identify whether a particular form field has changed or not during form submit.

Unfortunately, I'm not sure about such FORM utility for Struts.
And this *may* because, on each SUBMIT action, struts creates new instance of Action Form which has NO knowledge of previous Action Form rendered on EDIT page.

HTH
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Identify Form field changes in Struts
 
Similar Threads
Tracking field level changes
How to determine when a form field is submitted if it's changed from the original value?
How to identify changed fields
Multiple Instances of a field in a single FORM
Multiple Forms, Multiple Submissions