• 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: in which EO behalf a ValueFactory works?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: in which EO behalf a ValueFactory works?


  • Subject: Re: in which EO behalf a ValueFactory works?
  • From: Samuel Pelletier <email@hidden>
  • Date: Thu, 23 Aug 2018 09:32:32 -0400

Hi OC,

The ValueFactory methods are not well suited for you need. You want to create a
child relationship serialized in the parent object, not a simple storage for
basic container.

I suggest you try something like this with the model attribute for the
serialized content named attributeBlob with a NSData type:

- Implement a method public NSData _attributeBlob() that will returns the
serialized attribute.

- Implement a method public void _setAttributeBlob(NSData data) that will
unserialize your blob to an instance variable with the back link to it's parent.

- Add a getter for the real attribute object like public MyCustomObject
attribute()

- In the attribute object add a call to willChange() on the parent EO in method
that mutate the object.

EOF will uses the method with an '_' during fetch and save if they exists
(StoredValueForKey: protocol) so you can uses theses for your encoding
decoding. The call to willChange() will add the object in the EOEditingContext
changed objects.

I've done something similar without the backlink part in the past.

Regards,

Samuel


> Le 22 août 2018 à 13:31, ocs@ocs <email@hidden> a écrit :
>
> Hi there,
>
> quite unrelated to the other things, I would need to exploit the
> ValueFactory/ValueConversion support of EOF to store my own complex values in
> BLOBs.
>
> There's a catch though: for a ValueFactory-generated object, I would need to
> know which EO it belongs to (so that, iff the object's own internal state
> changes, it can change the EO contents appropriately).
>
> Is there any way to do that?
>
> If important, here's the rationale: so far, I have used two distinct
> attributes, conceptually like this:
>
> ===
> class DBSomething extends ERXCustomObject {
>   NSData attributeBlob() { storedValueForKey("attributeBlob") } // modelled.
> Never used directly, but for the cases below
>   MyCustomObject attribute() { new
> MyCustomObject(attributeBlob,this,"attributeBlob") }
> }
> class MyCustomObject {
>   MyCustomObject(NSData contents, ERXEnterpriseObject owner, String key) {
>     ... ...
>     NSData blobRepresentation() { ... ... }
>     void didChange() { owner.takeStoredValueForKey(blobRepresentation(), key)
> }
> }
> ===
>
> but it seems to me it would be cleaner if I could defer creation of
> MyCustomObject to the ValueFactory, storing the changes to the
> ValueConversion, and get rid of the ugly dichotomy of foo and fooBlob,
> removing fooBlob completely and seeing only foo (of type MyCustomObject) at
> the code level.
>
> Thanks and all the best,
> OC
>
> _______________________________________________
> 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

 _______________________________________________
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

References: 
 >in which EO behalf a ValueFactory works? (From: "ocs@ocs" <email@hidden>)

  • Prev by Date: Re: Weird D2W rule selection
  • Next by Date: Re: OSCPool/EO stack management/relaunch (was: Should ERXEC get sharedEC automagically?)
  • Previous by thread: in which EO behalf a ValueFactory works?
  • Next by thread: WOlips Installation problem
  • Index(es):
    • Date
    • Thread