• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the max value for an entity's attribute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Getting the max value for an entity's attribute (From: Jeff Dunnett <email@hidden>)

  • Prev by Date: Writing maintainable and extendable D2W rules
  • Next by Date: RESTful EOAdaptor for key-value stores
  • Previous by thread: Getting the max value for an entity's attribute
  • Next by thread: Writing maintainable and extendable D2W rules
  • Index(es):
    • Date
    • Thread