Re: How To Check Attribute's Width Programmatically?
Re: How To Check Attribute's Width Programmatically?
- Subject: Re: How To Check Attribute's Width Programmatically?
- From: Anjo Krank <email@hidden>
- Date: Thu, 5 Feb 2004 23:22:57 +0100
- Xx-reply-to: email@hidden
Am 05.02.2004 um 23:07 schrieb email@hidden:
I realize you can set and get attributes of an entity or table
programmatically (using either takeValueForKey or valueForKey())
Not quite: you get the attribute value of an enterprise object. The
"attribute" itself is an object describing what can be contained in the
value.
I would however like to retrieve the maximum possible width of the
attribute in my program. I ask this because of so : I have an
attribute first_name in my table Subscribers. Its width attribut is
150 varchar2().
Now when subscribers are entering the first_name field through the web
interface I would like to do some length check (what if the subscriber
enters a name longer than 150 characters?) (please bear with me this
is just an example albiet a bad one)
You should name your attribute in java convention, ie. "firstName", not
"first_name". first_name should be the name of the column in the
database.
In my validation mathod I would like to check if the string entered is
greater than the set width of the field of the table (whatever it may
be). I can put in a preset 150 characters but that is no fun (because
if you change the character width later on you will have to go through
the code and change all instance of 150 character width).
Is it possible to retrieve the width of an attribute in the program ?
Sth like:
EOEnterpriseObject eo; // assume this is given
int width = EOUtilities.entityNamed(eo.editingContext(),
eo.entityName()).attributeNamed("foo").width();
Cheers, Anjo
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.