Hi,

We had a similar kind of issues in our last project and we thought about a methodology 
also. 
Please let me know if there are any issue with this or somewhere it needs correction 
or is a performance bottle neck etc etc.
 

I will explain it with an example. We had a screen called Asset Details having 
following sections

Asset Overview (Textboxes and Drop downs + 1 Textarea comment box)

Asset Comparative Statistics(Textboxes and Drop downs + 1 Textarea comment box)

Asset Highlights (2 Textarea comment box)

Asset Pricing (Textboxes and Drop down)

Instead of making a single VO we made 4 VOs for each of the sections. Every VO has a 
method called isDirty() and dirtyLog(). The dirtyLog() method used to take the object 
of the same class as parameter and in the method compares the fields with its own 
internal fields. The changed fields where put into a concatenated string. The reason 
for dong so was that the client wanted to have the log for whatever changes happened 
in the screen against the user id that has done this change.

 

So method looked something like this 

 
Public class AssetOverviewVO()
{
            public String dirtyLog(AssetOverviewVO assetOverviewVO)

{
            if                          
(!this.strAssetManager.equals(assetOverviewVO.getAssetManager())

        {

            dirty = true;
            strChangedLog.append(" Asset Manager " )
            strChangedLog.append(" Old Value : " )
            strChangedLog.append(assetOverviewVO.getAssetManager())
            strChangedLog.append(" New Value : " )
            strChangedLog.append(this.strAssetManager)
}

 
        //Similarly we did it for all the fields. We wrote a utility excel macro to    
 do the value object generation.

        }

}

In DAO we used to check that if that section is dirty then we save it else leave it. 
Only problem was with the comments fields as the string comparison for them might have 
created a performance issue.

For them we kept hidden variables in the form itself. Whenever there is a change we 
marked it as true. In the ActionClass we set the isDirty() method to true if there is 
any change in the comments.

One issue with this design is that the last generated set of VOs has to be kept in the 
session. We had a method in a baseaction class to flush out the VOs of last requests 
and put the VOs of latest requests in the session if there are no exceptions. Again 
this method can be called from each of the action mehod where u are setting the form 
from the VO.

Please let me know if it suites your requirement

KP

-----Original Message-----
From: Milind Kulkarni [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 25, 2004 3:09 PM
To: 'Struts Users Mailing List'
Cc: 'Dhanesh Vasandani'
Subject: RE: Design Issue - Unchanged data getting submitted

Hi,

Update record problem:

I assume that you have a Header record and multiple child records for this
header. To ensure that only the changed records are saved you will have to
mark them as "Changed" from the UI. And pass only the changed ones to
Business Layer so that only changed ones are saved. Since you are saying
that you have a complex form and multiple fields then it would be even more
trickier.

You can probably manage this problem using versioning. When you are updating
the record. Mark the existing records as inactive. Increment the counter
(version) and insert the new set of records. No doubt, you will end up with
multiple versions of records but then if you have any audit requirements
that will be satisfied using this approach.

Thanks,
Milind





  -----Original Message-----
  From: Viral_Thakkar [mailto:[EMAIL PROTECTED]
  Sent: Monday, May 24, 2004 7:42 PM
  To: Struts Users Mailing List
  Cc: Dhanesh Vasandani
  Subject: Design Issue - Unchanged data getting submitted


  Dear all,



  We have a application built using Struts.



  Below is the architecture in brief :



  JSP à Action Class à Business Delegate à Session Façade à Database



  We are not using Action forms. We are using Value Objects (VO) to pass
data between web tier and App tier (from action to EJB via Business
Delegate).



  Problem:



  We have a very big form with many input fields/select fields.



  There are two scenarios

    1.. Insert the record
    This seems fine. We take all the data entered by user on the screen in
action class, create VO and pass it to EJB which inserts into database.


    2.. Update the record
    Here we have a Problem.
    Screen is populated with data retrieved from database. Here user can
update few/all fields. All the fields are under one form. User clicks on
save button. Only one Save button is available on page which submits the
complete page. The problem is that even if user does not update/add any
value and clicks on save button, all the field values (unchanged and
changed, both) will pass till EJB and the whole record in database will get
updated but in reality update require only for changed fields.

    Screen is bit complex with all types of input fields with ADD MORE and
DELETE ROWS kind of functionality also.  Screen can not have more than one
SAVE button.

    Please let us know what to use to solve such kind of performance issues.




  Thanks & Regards,

  Viral

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to