Re: WOToOneRelationship and "dirty" editing context
Re: WOToOneRelationship and "dirty" editing context
- Subject: Re: WOToOneRelationship and "dirty" editing context
- From: email@hidden
- Date: Thu, 5 Jan 2006 16:00:36 -0500
Hi Lachlan,
Thanks for your input.
On 05 Jan, 2006, at 02:12 PM, Lachlan Deck wrote:
Hi there,
On 06/01/2006, at 4:16 AM, email@hidden wrote:
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";
}
(FYI. I followed some tips on Kieran's website (http://
homepage.mac.com/kelleherk/iblog/C183784902/E951811406/index.html)
to display all of the departments contained in my Department
Entity. This is because I have ERExtensions as part of my
application's frameworks.... Thanks Kieran!).
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.
Try updating your User like...
public void setDepartment( Department aDepartment ) {
Department currentDepartment;
currentDepartment = department();
if ( currentDepartment != aDepartment ) {
...
}
}
That way your entity will not "update" itself when you're simply
giving it the same value.
While this may work to avoid updating the entity itself, it will
1) break our existing auditing scheme that relies on monitoring the
editing context's updatedObjects NSArray.
2) require us to manually update nearly all of our entities in our
application (well over 200 that will have to one relationships) with
customized code.
This seems like a lot of work in order to use an interface component
(WOToOneRelationship). I guess I am curious why any object gets
tagged as "updated" in the editing context before user manipulation
when using this component? Is it an EOF issue or they way the
WOToOneRelationship works? I have tried the ERXToOneRelationship and
it too has the same effect of tagging my object as modified upon
initial display.
In the old post I referenced (http://www.wodeveloper.com/omniLists/
webobjects-dev/2000/November/msg00119.html), the author mentioned
that WOToOneRelationship uses the takeValueForKey instead of the
validateTakeValueForKey, and somehow this registers a change in the
editing context even values are unchanged. I could not find either
of these in the source for WOToOneRelationship, so I am not sure if
this was fixed in later versions of WO.
I am still very new to WO, so sorry if this is so basic.
with regards,
--
Lachlan Deck
Thanks again,
Kev
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden