ERD2WEditToOneRelationship and enums: the correct way to use them?
ERD2WEditToOneRelationship and enums: the correct way to use them?
- Subject: ERD2WEditToOneRelationship and enums: the correct way to use them?
- From: Ângelo Andrade Cirino <email@hidden>
- Date: Thu, 15 May 2014 12:47:28 -0300
Hi,
I want to use a ERD2WEditToOneRelationship in a D2W page with a statically defined list of options using an enum for the list. I've followed the presentation in the screencast "D2W Custom Assignments and Component Design (WOWODC 2010)".
I've set up this rules:
100 : (propertyKey = 'person.gender' and entity.name = 'Party' and task = 'edit') => componentName = "ERD2WEditToOneRelationship" [com.webobjects.directtoweb.Assignment]
100 : (propertyKey = 'person.gender' and entity.name = 'Party' and task = 'edit') => keyWhenRelationship = "name" [com.webobjects.directtoweb.Assignment]
100 : (propertyKey = 'person.gender' and entity.name = 'Party' and task = 'edit') => restrictedChoiceKey = "object.person.genders" [com.webobjects.directtoweb.Assignment]
But when the entity is updated the following exception is thrown:
IllegalArgumentException: While trying to invoke the set method "public void models._Person.setGender(java.lang.Integer)" on an object of type models.Person we received an argument of type enums.Genders. This often happens if you forget to use a formatter.
at com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.throwMethodExceptionWithDescription(NSKeyValueCoding.java:1128)
And in my entity Person I have
public NSArray<enums.Gender> genders() {
return new NSArray<enums.Gender>(enums.Gender.values());
}
ERD2WEditToOneRelationship correctly uses the Gender name, so I expected it to use the value in the Gender enum, but it doesn't seem to do so when assigning the entity attribute gender.
A little help with this will be very valuable, since it seems so simple to work with enums and ERD2WEditToOneRelationship to represent static lists of values.
Thanx,
Angelo
_______________________________________________
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