• 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 No. 2 [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validation Problem No. 2 [SOLVED]


  • Subject: Re: Validation Problem No. 2 [SOLVED]
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Mon, 28 Apr 2003 09:45:19 +0100

George, MMalc, Bob,

Thank you very much for helping me through this, all your suggestions were seriously appreciated. I tested them both and each work wonderfully well.

Much appreciation
Jonathan :^)




From: George Domurot <email@hidden>
To: "Jonathan Fleming" <email@hidden>
CC: email@hidden, Bob Stuart <email@hidden>
Subject: Re: Validation Problem No. 2
Date: Sun, 27 Apr 2003 12:08:40 -0400

I believe Bob is right. You should use the editingContext of the object your are validating within. However, I believe you will still need to update your condition to avoid getting caught on your update. Try this out:

public String validateImagePosition(String newImagePosition)
       throws NSValidation.ValidationException {

// Jonathan, you might want to check for the length of the trimmed off string
//
if (newImagePosition == null || newImagePosition.trim().length()==0)
throw new NSValidation.ValidationException("You must set the image position Eg. the order in which it will list. \"01 - first\", \"02 - second\", \"03 - third\", \"04 - fourth\" etc.");


	NSMutableDictionary lookup = new NSMutableDictionary();
	int tbClientID_int = Integer.parseInt( tbClient().sTb_ClientID() );
	Integer id = new Integer(tbClientID_int);
	lookup.setObjectForKey(newImagePosition, "imagePosition");
	lookup.setObjectForKey(id, "tbClientID");

NSArray result = EOUtilities.objectsMatchingValues(this.editingContext(), "TbClientData", lookup);
NSLog.out.appendln("===\r result matching values " + result + "");
NSLog.out.appendln("===\r lookup dict " + lookup + "");
NSLog.out.appendln("===\r new image position is set to: " + newImagePosition + "");


if (result.count() > 1 || (result.count()==1 && !result.objectAtIndex(0).equals(this)))
throw new NSValidation.ValidationException("The position you tried to set for this image is already taken. Please choose another. Tip: look in your list of images below for the picture sort order.");


	return newImagePosition;
}

On Sunday, April 27, 2003, at 08:21 AM, Bob Stuart wrote:

Jonathan,
try this. warning code not tested :)
//instead of a new ec use this objects ec
//If we use a new ec the equals will not match since we will be same values in
//different ec.
EOEditingContext ec = this.editingContext();
//verify we are in an ec and put appropriate error if not
if (ec == null) {
//bad we were not inserted before someone invoked a validate
}



//There is a match and it is not myself
if (result.count() == 1 && !this.equals(result.lastObject()) ) {


At 9:10 AM +0100 4/27/03, Jonathan Fleming wrote:
In this validation method i am trying to check the no two numbers of a NSArray of static numbers (of type String) are duplicated either on save or an update, however, what is happening is that the method notifies me well enough on save that I have already chosen for example "02" if "02" is already set to another image, but when I update whether I have made any changes to my EO propeties or not I always get my error message for this method because obviously there is an item in the dictionary equal to 1. How do i get around this so that it reads correctly on an update?

Thanks
Jonathan :^)

public String validateImagePosition(String newImagePosition)
       throws NSValidation.ValidationException {

if (newImagePosition == null || newImagePosition.equals("")) {
throw new NSValidation.ValidationException("You must set the image position Eg. the order in which it will list. \"01 - first\", \"02 - second\", \"03 - third\", \"04 - fourth\" etc.");
} else {
NSMutableDictionary lookup = new NSMutableDictionary();


int tbClientID_int = Integer.parseInt( tbClient().sTb_ClientID() );
Integer id = new Integer(tbClientID_int);
lookup.setObjectForKey(newImagePosition, "imagePosition");
lookup.setObjectForKey(id, "tbClientID");


EOEditingContext ec = new EOEditingContext();
NSArray result = EOUtilities.objectsMatchingValues(ec, "TbClientData", lookup);
NSLog.out.appendln("===\r result matching values " + result + "");
NSLog.out.appendln("===\r lookup dict " + lookup + "");
NSLog.out.appendln("===\r new image position is set to: " + newImagePosition + "");


if (result.count() == 1) {
throw new NSValidation.ValidationException("The position you tried to set for this image is already taken. Please choose another. Tip: look in your list of images below for the picture sort order.");
}
}
return newImagePosition;
}


_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger


_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev


--
Bob Stuart
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev



_________________________________________________________________
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.

  • Prev by Date: Re: Validation Problem
  • Next by Date: Re Fetching Raw Rows
  • Previous by thread: E-mail Receivedwebobjects-dev digest, Vol 1 #219 - 1 msg
  • Next by thread: Re Fetching Raw Rows
  • Index(es):
    • Date
    • Thread