Re: Limiting Selection In a WOBrowser
Re: Limiting Selection In a WOBrowser
- Subject: Re: Limiting Selection In a WOBrowser
- From: "Jonathan Fleming" <email@hidden>
- Date: Fri, 17 Jan 2003 23:24:49 +0000
From: Art Isbell <email@hidden>
To: "Jonathan Fleming" <email@hidden>
Subject: Re: Limiting Selection In a WOBrowser
Date: Fri, 17 Jan 2003 09:12:05 -1000
On Friday, January 17, 2003, at 04:49 AM, Jonathan Fleming wrote:
Is there a way to Limit the number of selections a user can make in a
WOBrowser?
I think the HTML object underlying WOBrowser allows only single or
multiple selections, not a specified number like 2.
So you'd need to programmatically count the number of objects in the array
bound to WOBrowser's "selections" key when the form is submitted. If the
number is >2, return the same page but with an error message displayed,
ideally close to the browser.
I use NSValidation for validating my EOCustomObject Classes, the
"selections" binding is bound to the NSArray of the EOCustom Class
(JobPictures) jobPicture.jobType_categories which has a manyToMany
relationship with the (Category) EOCustom Class.
I susspect I would write my if statement such as:
public void validateForSave( ) throws NSValidation.ValidationException {
super.validateForSave( );
String jobType_categories = jobType_categories( );
if ( jobPicture.jobType_categories.count >2 ) {
throw new NSValidation.ValidationException
( "You can only select 2 categories from the list")
}
}
Would that do it? Or is my if argument wrong?
these are the methods in the JobPicture (EOCustomObject Class) which the
"selections" binding is bound to:
public NSArray jobType_categories() {
return (NSArray)storedValueForKey("jobType_categories");
}
public void setJobType_categories(NSMutableArray value) {
takeStoredValueForKey(value, "jobType_categories");
}
public void addToJobType_categories(Category object) {
NSMutableArray array = (NSMutableArray)jobType_categories();
willChange();
array.addObject(object);
}
public void removeFromJobType_categories(Category object) {
NSMutableArray array = (NSMutableArray)jobType_categories();
willChange();
array.removeObject(object);
}
Jonathan
Art
http://homepage.mac.com/aisbell/
_________________________________________________________________
Help STOP SPAM: Try the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
_______________________________________________
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.