EOGenerator templates
EOGenerator templates
- Subject: EOGenerator templates
- From: Greg Hulands <email@hidden>
- Date: Thu, 21 Oct 2004 08:46:50 +1000
Hi,
I am trying to add automatic validating to any string attribute by
making sure that the length of the string won't excced the width of the
attribute.
The problem I am having is trying to get the comparison correct. I have
tried == with no luck. I also have tried NSString instead of
java.lang.String.
<$if Attribute.className.isEqualToString("java.lang.String")$>
public Object
validate<$Attribute.name.initialCapitalString$>(Object value) {
String str = (String)value;
EOEntity <$classNameWithoutPackage$> =
EOModelGroup.defaultGroup().entityNamed(entityName());
EOAttribute attr<$Attribute.name.initialCapitalString$> =
<$classNameWithoutPackage$>.attributeNamed("<$Attribute.name$>");
if (str.length() >
attr<$Attribute.name.initialCapitalString$>.width()) {
return str.substring(0,
attr<$Attribute.name.initialCapitalString$>.width() - 1);
}
return str;
}
<$endif$>
Does anyone know if this is possible?
Greg
_______________________________________________
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