Re: Making changes to EO after validation?
Re: Making changes to EO after validation?
- Subject: Re: Making changes to EO after validation?
- From: Stirling Olson <email@hidden>
- Date: Thu, 12 May 2005 22:58:56 -0600
Hi Anjo!
I'm not sure I understand what you are suggesting. I'm not having
any trouble with the validation checks only a last moment update I'd
like to make.
If a user claims a different cash value (Shift.endingCashBoxBalance)
than what the system "thinks" should be in the cash box
(CashBox.balance) then I want to update the CashBox.balance when
saving the user's Shift but only after I'm sure it will save and save
with the proper discrepancy comments from the user. I'm just calling
validateForUpdate in my components BEFORE saving the Shift for now.
This way I only do one save and the process is atomic. The reason I
only want to update CashBox.balance when I know for sure that the
save will work is because then my EO validation, which checks that a
discrepancy comment is posted when the CB.balance != the
Shift.endingCashBoxBalance, will work even on 2nd and 3rd attempts by
the user to end (i.e. save) the Shift. Anyhow, sounds like there is
no way in the EO to change attributes after validation and before
the actual save. I think this just means that I have to pull that
"business logic" out of the EOs and put them in the components. Not
the way I was hoping to do it but it will work.
Thanks for your help.
-Stirling
On May 12, 2005, at 10:40 PM, Anjo Krank wrote:
Am 13.05.2005 um 03:59 schrieb Stirling Olson:
I have Shift and CashBox EOs. When I try to close out a Shift and
Shift.endingCashBoxBalance != CashBox.balance the validation fails
UNLESS a discrepancy note has been added to the Shift EO. What I
would like to do is to update the CashBox.balance but ONLY after
all other validations have occurred and have been successful.
This allows for me to keep the "old" CashBox.balance until all
other validation problems have been cleared up. I can trick this
behavior in the components by saving twice (i.e. updating
CashBox.balance and then doing a second saveChanges() if the first
succeeded) but what I'm trying to do seems to me like a business
logic problem and therefore I'd like to put it in my EOs and not
in the apps themselves. FYI: CashBox is related to Shift through
Shift.cashBox().
I don't really understand your problem: can't you just have a
Shift.endingBalance = Shift.endingCashBoxBalance +
email@hiddenepancy and check if *that* isn't equal to
CashBox.balance?
The purpose for the didSave stuff is mainly for logging or tracking
changes, like creating a new "TranslationTask" when a text has
changed or a "Change" item. In that case when you'd save, in
didSave you create your EO, create your object and *make damn sure
it can save* then save again.
Cheers, Anjo
_______________________________________________
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