Hi All,
I am using a WOToOneRelationship and having some issues with the editing context becoming "dirty" when no changes are made to the object itself.
I have a User entity with a "to one" relationship (department) to my Department entity. Here are the bindings for the WOToOneRelationship component in WOBuilder used modifying an instance of the User entity, called validatedUser.
WOToOneRelationship1: WOToOneRelationship { relationshipKey = "department"; sourceObject = mySession.validatedUser; sourceEntityName = "User"; uiStyle = "popup"; dataSource = allDepartments; destinationDisplayKey = "shortDescriptor"; }
All is working fine and I can display the validatedUser (an instance of the User Entity) and his/her department. If I change the department from the WOToOneRelationship popup, and save the changes to the editing context, the changes are saved successfully to the database.
My problem is that when I merely display the validatedUser and do not make any changes, I am still seeing the object as being updated by logging the updatedObjects() of the editing context. If I remove the WOToOneRelationship from the page, and replace with a simple WOTextField, I do not see the object as being updated , when I do not perform any changes to the user. This is the behavior I would like to see, and would expect, when using WOToOneRelationship.
Here is the code to save which
public WOComponent saveUserSettings() { System.out.println("Here are the modified objects going to be saved: " + mySession().validatedUser().editingContext().updatedObjects()); mySession().validatedUser().editingContext().saveChanges(); return pageWithName(_referingPageName); }
Since I need to audit all changes made to objects by the end users of my application, I do not want to necessarily want to have additional overhead of figuring out if the object is really changed anytime I use this WOToOneRelationship component. I read in an old post (circa 2000) that this behavior is due to the way the WOToOneRelationship is written, but not sure if there is a workaround or if I am doing something incorrectly.
Thanks for any help,
Kev |