There are times when a WebObjects programmer may find it useful to build a custom attribute type in a custom attribute class. This is not very difficult and directions can be found in the WebObjects 4.5 'EOF Developer's Guide'; 'Modeling Complex Attributes' Chapter; 'Custom Data Types' Section, which is located at:
The difficulties arise because the Java language provides for Packages, which can be used to group related objects or interfaces, and can provide a means of name space protection. Getting custom attribute types to work can be tricky if the custom attribute class is not in the same package as the Enterprise Object class.
There are four things you must do to get this to work properly in Java:
Here is an example (the rest of the class is constructors and setters and getters and so forth):
// EOF valueFactoryMethodName
public static PhoneNumber objectWithArchiveData(String str) {
System.out.println("factory Here...");
PhoneNumber phone = new PhoneNumber(str);
return phone;
}
// EOF adaptorValueConversionMethodName
public String archiveData() {
return _wholePhone;
}
// EOF bug workaround
public Object clone() {
System.out.println("clone Here...");
return this;
}
Here is the relevant snippet from the EO:
{
adaptorValueConversionMethodName = archiveData;
allowsNull = Y;
columnName = PHONE;
externalType = CHAR;
factoryMethodArgumentType = EOFactoryMethodArgumentIsNSString;
name = phone;
valueClassName = PhoneNumber;
valueFactoryMethodName = "objectWithArchiveData:";
width = 10;
},