Re: validatating to-many relationship
Re: validatating to-many relationship
- Subject: Re: validatating to-many relationship
- From: Fabian Peters <email@hidden>
- Date: Fri, 01 Nov 2013 14:04:20 +0000
Hi Markus,
Assuming you are using a tab or wizard page, you can use a rule like this to have your validation method called:
100 : (pageConfiguration = 'CreateCourse' and tabKey = 'Location') => validationKeys = ("validateLocation") [com.webobjects.directtoweb.Assignment]
You may have to use a custom validation delegate to get the validation message to display: <https://github.com/wocommunity/wonder/issues/97>
Fabian
Am 01.11.2013 um 12:11 schrieb Markus Ruggiero <email@hidden>:
> I have D2W application where we have a to-many relationship. This relationship is displayed by a custom component. The user can check the desired destination objects (there are only 5 available). It is required that at least one checkbox must be ticked. In the EOModel the to-many relationship is set to not null.
>
> Default handling (validateForSave) returns an exception text "The relationship must have at least one assignment of type ?". Obviously EOF is not able to figure what the destination is and displays a question mark. I tried to implement validateIndustryProducts() but this method is never called. Overriding validateForSave and NOT calling super.validateForSave works but this does not feel right. How can I validate that relationship properly?
>
> Model Details: There is a qualified many-to-many relationship between a product and an industry. A product must be assigned to at least one of the 5 industries. For each assignment the user must give a free text primary use for that product in that assigned industry. The qualified join entity is called IndustryProduct and thus the relationship on product is called industryProducts. Here is my code from Product that does not get called:
>
> public Object validateIndustryProducts(Object value) throws ValidationException {
> if (industryProducts() == null || ((NSArray)industryProducts()).count() == 0) {
> throw new ValidationException( "At least 1 industry must be assigned" );
> }
> return value;
> }
>
> What do I miss?
>
> Thanks a lot
> ---markus---
>
>
>
>
>
> Markus Ruggiero
> email@hidden
> Check out the new book about Project Wonder and WebObjects on http://learningthewonders.com
>
>
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden