Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Identify Form field changes in Struts

 
Shriram Gopalakrishnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shriram Gopalakrishnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic