Catching Matching Values in User TextField against EO
Catching Matching Values in User TextField against EO
- Subject: Catching Matching Values in User TextField against EO
- From: "Jonathan Fleming" <email@hidden>
- Date: Wed, 23 Apr 2003 13:39:59 +0100
G'day Developers,
Hope you're all well and chirpy today.
Right, small problem solve for the fit...
I have a PopUpButton that simply lists numbers 01 - 50 set like this:
PopUpButton_imagePosition: WOPopUpButton {
list = aListOf_ImagePositions;
selection = tbClientData.imagePosition;
name = "imagePositions";
noSelectionString = "";
}
where tbClientData is my business logic EOCustomObject, however, I want to
be able to run a bit of code that will stop the user setting the EO with a
value that is already taken. For example if images ONE, TWO and THREE have
been given the positions 01, 02 and 03 repectivley then I want to stop the
user from setting his fourth image (FOUR) to 02 or any of the already
used-up position numbers.
Can someone help me out with what code I am supposed to use? In the meantime
I have been trying to use the code below but I can not figure out how to get
it to work properly (the bit of code we are concerned with starts at //
CHECK THAT THE IMAGE POSITION ISN'T ALREADY TAKEN (I sent the full method so
you can see what I am trying to do):
// ImagePosition = required
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.");
}
// CHECK THAT THE IMAGE POSITION ISN'T ALREADY TAKEN
EOEditingContext editingContext = new EOEditingContext();
//editingContext.setSharedEditingContext(null);
NSArray results =
EOUtilities.rawRowsMatchingKeyAndValue(editingContext, "TbClientData",
"imagePosition", imagePosition());
if (results.count() > 0) {
newImagePosition.equals("reset");
if (newImagePosition.equals("reset")) {
throw new NSValidation.ValidationException("The position
you set for this image: " + imagePosition() + " is already taken. Please
choose another");
}
}
return newImagePosition;
}
If there is an easier or better way than the route I am trying to take, I
welcome your suggestions.
Kind regards
Jonathan F :^)
_________________________________________________________________
Use MSN Messenger to send music and pics to your friends
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.