• 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: When Is Validation Triggered
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When Is Validation Triggered


  • Subject: Re: When Is Validation Triggered
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 03 Jun 2011 12:10:12 -0700

Hi Kevin,

On Jun 3, 2011, at 9:54 AM, Kevin Hinkson wrote:

Hi,
I've implemented the following on an EO:

public void validateForSave() throws NSValidation.ValidationException {
public String validateEmail(String newEmail) throws NSValidation.ValidationException {

validateEmail I assume is called by validateValueForKey so I can apply attribute specific checks.

It is actually called by validateTakeValueForKey.  That method is called by the WOForm elements (e.g. WOTextField) so that validation happens during the takeValueFromRequest phase.

validateEmail is also called by validateForSave, so you don't need to implement this validation twice (you DO need to call super.validateForSave()).


When one of my checks fail I do:

throw new NSValidation.ValidationException("Please enter a valid email address.");

In either case (with only one enabled at a time) validateForSave and validateEmail can be seen throwing an exception which I log but this is only thrown after the EO is inserted into the database which is done by saving the editing context.

The EO is in the database when you get this error?  That seems unlikely.  It should be thrown during ec.saveChanges() before getting written to the database.  Check the stack trace.


Is this how it is supposed to work? I thought that these would be triggered before insert: http://wiki.objectstyle.org/confluence/display/WO/EOF-Using+EOF-Validation and either would prevent insertion.

Am I doing it wrong?

I think that it is working correctly and that you are misinterpreting what you are seeing.  Can you post the stack trace from the NSValidation.ValidationException?


Chuck

-- 
Chuck Hill             Senior Consultant / VP Development

Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving!  Network, socialize, and enjoy a great cosmopolitan city.  See you there!  http://www.wocommunity.org/wowodc11/

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: When Is Validation Triggered
      • From: Kevin Hinkson <email@hidden>
References: 
 >When Is Validation Triggered (From: Kevin Hinkson <email@hidden>)

  • Prev by Date: When Is Validation Triggered
  • Next by Date: Re: When Is Validation Triggered
  • Previous by thread: When Is Validation Triggered
  • Next by thread: Re: When Is Validation Triggered
  • Index(es):
    • Date
    • Thread