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

Re: Validation Problem


  • Subject: Re: Validation Problem
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Mon, 28 Apr 2003 08:31:22 +0100

Thank you very much mmalcolm for all of your replied posts on this subject, the last two contained bits of code I never knew could be created. Very education.

Thanks again
Jonathan







From: mmalcolm crawford <email@hidden>
To: "Jonathan Fleming" <email@hidden>
CC: email@hidden
Subject: Re: Validation Problem
Date: Sun, 27 Apr 2003 13:52:04 -0700


On Sunday, April 27, 2003, at 01:20 PM, mmalcolm crawford wrote:

Assuming the user is entering the value in a text field, I wouldn't allow more than 255 characters into the field in the first place... [...]
You can calculate the maxlength dynamically from an EO's attribute:


If you do want to leave it up to the request-response cycle to check, you can also use WOComponent's validateTakeValueForKeyPath:


public Object validateTakeValueForKeyPath(Object value, String keyPath)
throws NSValidation.ValidationException {


            if (keyPath.equals("movie.rated") && (value != null)) {

                int length = ((String)value).length();
                EOEntity entity = EOUtilities.entityForObject
                    (movie.editingContext(), movie);

                int maxLength = entity.attributeNamed("rated").width();

if (length > maxLength)
throw new NSValidation.ValidationException("My own Exception: Movie rating cannot be longer than " + maxLength + " characters");
}


            return super.validateTakeValueForKeyPath(value, keyPath);

        }

mmalc



_________________________________________________________________
Get Hotmail on your mobile phone http://www.msn.co.uk/mobile
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Validation Problem
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: E-mail Receivedwebobjects-dev digest, Vol 1 #219 - 1 msg
  • Next by Date: Re: Validation Problem No. 2 [SOLVED]
  • Previous by thread: Re: Validation Problem
  • Next by thread: Re: Validation Problem
  • Index(es):
    • Date
    • Thread