• 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
Converting from one subclass to another
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting from one subclass to another


  • Subject: Converting from one subclass to another
  • From: David Avendasora <email@hidden>
  • Date: Wed, 13 Feb 2008 11:06:46 -0500

Hi all,

I have the following structure:

NutritionBlock <->> NutritionValue

The abstract NutritionValue is subclassed by StoredNutritionValue and CalculatedNutritionValue.

The two sublcasses are identical in their implementation except for the method valueAmount(). In StoredNutritionValue it does a lookup from the DB in the normal WO way. In CalculatedNutritionValue it actually calculates valueAmount() and doesn't look at the DB at all.

I am allowing the user to select which subclass each NutritionValue is. When they set it to Calculated, I'm expecting it to immediately use the CalculatedNutritionValue implementation of valueAmount() and return that value instead of the stored value.

The actual mechanics of changing subclasses seems to work just fine, but WO apparently still expects an object of the original subclass at the end of the relationship so it does some odd things until it is forced to reload from the Database and re-read the qualifier to tell it what class it is. Once I close the app and restart it comes up fine as the new subclass using the proper implementation for valueAmount()

I could just create a new object of the new class and delete the existing one, but this seems to be swatting a fly with a full set of encyclopedias.

What is the best way to get WO to pickup the subclass change immediately?

Or is this just a bad way of doing things?

Thanks,

Dave
_______________________________________________
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: Converting from one subclass to another
      • From: Mike Schrag <email@hidden>
  • Prev by Date: Re: Servlet HttpSession in webobjects?
  • Next by Date: [ANN] JBND update
  • Previous by thread: Re: Servlet HttpSession in webobjects?
  • Next by thread: Re: Converting from one subclass to another
  • Index(es):
    • Date
    • Thread