• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Event firing from changing EOs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Event firing from changing EOs


  • Subject: Re: Event firing from changing EOs
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 7 Jan 2008 13:37:05 -0800


On Jan 7, 2008, at 1:28 PM, Florijan Stamenkovic wrote:

Hm, this does not really work for me. My change events contain:

1. Changed EO
2. The key on which it changed
3. The old value (where applicable)

based on that I can extract:

4. The new value
5. The type of the property


The stuff I have already made relies on all of this information, so the notification simply will not do. And, IIRC, the mentioned notification only gets posted when you ask the EC to save changes. This is NOT what I need. I need immediate feedback.

They get sent at the end of the event. In a web app, that is at the end of the RR loop. For a client app, that would be after processing an event in the event loop. You might need to manually call ec.processRecentChanges() in your event loop code.



No words of wisdom on these methods, Chuck?

public void takeStoredValueForKey(Object value, String key)
protected void includeObjectIntoPropertyWithKey(Object eo, String key)
protected void excludeObjectFromPropertyWithKey(Object eo, String key)

API and some testing suggests that using them to fire events should do.

I have not used them for what you are describing so I am a little cautious to say "Yes, that will do it". I am not sure what happens, for example, if the object gets invalidated, or saved in another EC so that this EC updates. I think it doing what you are describing will work. I am not sure that these three methods will handle 100% of the cases. I'd take a look at these methods too:


public void turnIntoFault(EOFaultHandler faultHandler)
public void updateFromSnapshot(NSDictionary aSnapshot)



Except for the fact that they get called also when the objects are being initialized after construction. I'd have to work around that.

You should be able to set a flag in awakeFromFetch (or maybe some other method) before calling super and suppress the notifications while the flag is set.


Chuck

On Jan 07, 2008, at 16:19, Chuck Hill wrote:

What about the EOObjectsChangedInEditingContextNotification?

This notification is broadcast whenever changes are made in an EOEditingContext. It's similar to ObjectsChangedInStoreNotification, except that it contains objects rather than globalIDs.
...
Interface layer EODisplayGroups (not WebObjects WODisplayGroups) listen for this notification to redisplay their contents


That sounds like it may do what you want and send fewer notifications. IIRC, it is called at the end of the RR loop in a WO app, not sure about JC. I think this is part of what the processRecentChanges() or _processRecentChanges() method does.



Chuck


On Jan 7, 2008, at 7:55 AM, Florijan Stamenkovic wrote:

Guido,

Thanks for the reply. I do not need this for logging. Where I need it in are Java Client applications. I am just finishing up a library that will make it quite easy to build WO + Swing applications. The library is totally event driven, all the GUI controllers and all that stuff has been made to respond to events fired by EOs that have changed. So, the end purpose is keeping the GUI in synch with the current state of EOs.

So, if the changes in the end get saved to the database or not is not relevant in my scenario.

That being said, what do you think? Till now my solution was to use EOGenerator to define setters that take care of event firing, when needed. This works, but I always wanted to do this more elegantly, and overriding the mentioned methods seems just about right. I am just wondering if EOF can at any time for any reason bypass them. Reading the API makes me think it can not, but I wanted to check...

Flor

On Jan 06, 2008, at 19:03, Guido Neitzer wrote:

On 06.01.2008, at 15:53, Florijan Stamenkovic wrote:

I am trying to make an EOGenericRecord subclass that will automatically fire events when new values are set. It is imperative that the event firing is absolute, nothing can be allowed to slip by, if a property changes in any way, an event has to be fired.

Hmm. Do you want to log the change in the EO or the change in the database? Because if you log changes to the EO, you might end up with logged stuff that was never saved and therfor does not exist outside the scope of where the change happened (and was reverted).


What I did for logging changes to EOs was checkin in "willUpdate" (using Wonder) by getting the changes from the snapshot. I also have some code to check whether relationships change but that is not really thought out completely.

cug

--
http://www.event-s.net


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net


This email sent to email@hidden



--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
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


  • Follow-Ups:
    • Re: Event firing from changing EOs
      • From: Florijan Stamenkovic <email@hidden>
References: 
 >Event firing from changing EOs (From: Florijan Stamenkovic <email@hidden>)
 >Re: Event firing from changing EOs (From: Guido Neitzer <email@hidden>)
 >Re: Event firing from changing EOs (From: Florijan Stamenkovic <email@hidden>)
 >Re: Event firing from changing EOs (From: Chuck Hill <email@hidden>)
 >Re: Event firing from changing EOs (From: Florijan Stamenkovic <email@hidden>)

  • Prev by Date: Re: Can't retrieve cookies
  • Next by Date: Re: Entity Modeler + Veogen problems and questions
  • Previous by thread: Re: Event firing from changing EOs
  • Next by thread: Re: Event firing from changing EOs
  • Index(es):
    • Date
    • Thread