4 Replies Latest reply on Mar 15, 2013 9:50 AM by ramp

    find Form bean changes in Action

    996699
      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.
        • 1. Re: find Form bean changes in Action
          gimbal2
          993696 wrote:
          Your suggestions are very mush appreciated.
          You should look for a struts forum. This is not one, the fact that you choose to post in the servlet forum and not ask a servlet question should have tipped you off.
          • 2. Re: find Form bean changes in Action
            996699
            Oh sorry,Could you give me the link of Struts Forum.
            • 3. Re: find Form bean changes in Action
              gimbal2
              How about.... on the struts website? Captain obvious should not have needed to rescue you today.
              • 4. Re: find Form bean changes in Action
                ramp
                There is no out of the box approach to achieve this. If your application collects form data into a DTO object, you could probably hold that object in session and compare it with the form object for differences.

                Another option would be to maintain a boolean field (for each form field) which toggles its state when the form field is changed.
                  public class <XXX>Form extends ActionForm{
                     private String xxxField;
                     private boolean xxxFieldIsDirty;
                
                     public void setXXXField(String val){
                       this.xxxField = val;
                       xxxFieldIsDirty = true;
                    }
                
                   .....
                You will have to then write some reflection code that returns you the 'dirty' fields of the form. You will also have to reset all the isDirty fields to false before the response goes out.