Validation Problem 3
Validation Problem 3
- Subject: Validation Problem 3
- From: "Jonathan Fleming" <email@hidden>
- Date: Tue, 29 Apr 2003 09:44:03 +0100
Hi Guys,
I want to try and swap one eo value with another if that value is already
set, but I can not think how to go about it, if you have any pointers, code
or anything of the like I would appreciate it.
Eg.
if TbClientData pkID3 is set to attribute: imagePosition with the value:
"09" and I want to swap or change it's value (imagePosition) to "04" how
would I simply swap those values with each other if "04" is already the
value of pkID2 for instance?
Basically I'd like to find out how to swap the current value of "09" with
the new value of "04" if it is already a value taken up by an EO in the
database or EOModel.
I already have unique validating on this attribute so that no two values can
be the same at the same time and I include the method here if it helps
Many thanks
Jonathan :^)
public String validateImagePosition(String newImagePosition)
throws NSValidation.ValidationException {
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);
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;
}
wop-bam-boo-bam-bam-ma-ling-a-dong all day long I wantcha singing this
song... just something stupid to try and brighten up your day, anyhow...
_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
_______________________________________________
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.