Modification Detection

All DTO classes come with the functionality to automatically detect whether any of the data the hold has been modified. With this functionality you can easily implement functionality like avoiding a database access or a service call when a user presses a ‘Save’-button without having modified any data.

Every DTO class that relates to a modeled display has its own dirty flag. Every setter of such a DTO class sets dirty = true in case the new data is different from the already available data. The DTO class that relates to a modeled layout does not have a dirty flag but provides the method isDirty() that checks all reachable instances of DTO classes to find out whether it can find a dirty object. The method isDirty() returns true if it can find at least one dirty DTO instance.

Note

The default value of dirty is false when you create a new DTO instance.

Additionally, every DTO class has a method clearAllDirty(). This method resets all dirty flags of all reachable DTO instances to false. With this, the order of executing code to handle DTOs is as follows:

  1. Get the data that you want to use to fill DTO instances, e.g. from a database or a service call.
  2. Create DTO instances.
  3. Fill the DTO instances with data.
  4. Call clearAllDirty() on the DTO class that corresponds to the modeled layout.