aspose file tools*
The moose likes Struts and the fly likes How to find ActionForm bean changes in struts Action? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to find ActionForm bean changes in struts Action?" Watch "How to find ActionForm bean changes in struts Action?" New topic
Author

How to find ActionForm bean changes in struts Action?

velMurugan vasu
Greenhorn

Joined: May 21, 2012
Posts: 13

I have a requirement in struts 1.2 framework where i have 50 to 60 fields in my form in which i have to update only 3Fields(which are changed by the user) so when i submit the form only these 3Fields needs to be updated in the database.

How can i identify the 3 changed/modified fields out of 50 fields in the struts ActionForm.
Your suggestions are very mush appreciated.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

One approach is to keep a copy of the form in the session and compare the submitted value. Another approach (if you don't have to worry about hackers) is to use JavaScript to note which fields change.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
velMurugan vasu
Greenhorn

Joined: May 21, 2012
Posts: 13

Hi Jean Thank you for your reply,Yes we can use javascript but for 50 to 60 fields we have to write huge script but in java we have PROPERTY CHANGE LISTENER that will fire when the user changes the value of the bean but in lot of forum they said this listener is good only for SWING for MVC is not a good idea to use,Also in JSF we have VALUECHANGE LISTENER could you tell me we have this feature in JSP.Are you have any other better solution apart from script and session.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

It's Jeanne, not Jean. Anyway, it doesn't have to be a lot of JavaScript. With this jQuery example, you can trigger an event on any field changing. Then you would keep track of the name in a hidden field and submit that field to the server. extJS has a similar example

JSP is a server side language to generate HTML (or other formats). Since it runs on the server, it isn't going to be able to tell you something changed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find ActionForm bean changes in struts Action?