• 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
EOGenericRecord vs. storedValue methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

EOGenericRecord vs. storedValue methods


  • Subject: EOGenericRecord vs. storedValue methods
  • From: Patrick Robinson <email@hidden>
  • Date: Fri, 25 Aug 2006 17:28:04 -0400

I've been experiencing some confounding property validation behavior, and I just figured out how to reproduce it. I get one behavior if my EO class is EOGenericRecord, and a different behavior if it's a custom class using the storedValue methods.

I've got a WOTextField bound to a Number attribute of an EO, and I've implemented validationFailedWithException() in the usual way:

public void validationFailedWithException(Throwable e, Object value, String keyPath) {
try {
takeValueForKeyPath(value, keyPath);
} catch (IllegalArgumentException iae) {
// ignore
}
super.validationFailedWithException(e, value, keyPath);
}


Now here's the bizarre part. If the EO's class (as set in EOModeler) is EOGenericRecord, and I enter non-numeric data in the form field, then when validationFailedWithException() is called (so that keyPath is someEO.someNumber), it calls takeValueForKeyPath(), and successfully puts the bad data back into the EO's someNumber attribute (that is, no IllegalArgumentException is thrown), and the user sees the bad data he entered in the form field.

However, if I make a custom class for the entity, and generate the class files as usual so that the accessors look like this:

    public Number someNumber() {
        return (Number)storedValueForKey("someNumber");
    }
    public void setSomeNumber(Number aValue) {
        takeStoredValueForKey(aValue, "someNumber");
    }

If I do that, and then enter non-numeric data in the form field bound to someEO.someNumber, then the call to takeValueForKeyPath() in validationFailedWithException() throws an IllegalArgumentException, and the bad data does NOT make it back to the form field, and the user does NOT see the bad data that he entered.

Is this just one of the side effects of EOGenericRecord's using dictionaries to store what are, conceptually, instance variables? Since it's a dictionary, it can cram any kind of object you want in there, at least while it's bouncing around the UI. Coercing data to the right types can be put off 'til validation and saving to the db?


-- Patrick Robinson AHNR Info Technology, Virginia Tech 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


  • Follow-Ups:
    • Re: EOGenericRecord vs. storedValue methods
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: Xcode 2.4 Deprecation Announcements
  • Next by Date: Re: Xcode 2.4 Deprecation Announcements
  • Previous by thread: Re: Xcode 2.4 Deprecation Announcements [Entity Modeler]
  • Next by thread: Re: EOGenericRecord vs. storedValue methods
  • Index(es):
    • Date
    • Thread