Re: Getting the max value for an entity's attribute
Re: Getting the max value for an entity's attribute
- Subject: Re: Getting the max value for an entity's attribute
- From: Stefan Klein <email@hidden>
- Date: Thu, 12 Nov 2009 16:40:10 +0100
Hi,
you can ask the EOModel:
EOEntity entity =
EOModelGroup.globalModelGroup().entityNamed(_Login._ENTITY_NAME);
EOAttribute attribute =
entity.anyAttributeNamed(_Login.WEBBROWSERINFO);
int len = attribute.width();
Stefan
Jeff Dunnett schrieb:
Hello,
I have an Entity named Login. It has an attribute named
webBroswerInfo that is a string. Is there any way for me to determine
in code he maximum size of that string? What I would like to do is
have a validation method that checks the size of the string and then
truncates the string if it is above the max length for the attribute.
I would like a way to do this dynamically rather then hard coding the
max max value.
For instance:
I currently have this:
public String webBrowserInfo(String value) throws
NSValidation.ValidationException {
if(value.length() > 255){
value = value.substring(0, 254);
}
return value;
}
I would rather have something like this:
public String webBrowserInfo(String value) throws
NSValidation.ValidationException {
if(value.length() > WEB_BROWSER_INFO_MAX_LENGTH){
value = value.substring(0, WEB_BROWSER_INFO_MAX_LENGTH);
}
return value;
}
I would like to be able to change the max length in the EOModel and
not have to worry about changing code. I suspect that there is a way
to do this but I am perhaps looking in the wrong place.
Regards,
Jeff
_______________________________________________
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