Converting from one subclass to another
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