The field in 1.x is abstracted away from the
validator so that it’s really only working with the value. Because of
the way Validators are generated there isn’t even really a field property
on the Validator, it’s just a code-gen construct that is used to register
the Validator in a larger system. 2.0 should give you more exposure to that.
Matt
From: [email protected] [mailto:[email protected]] On Behalf Of Kai König
Sent: Thursday, August 18, 2005
6:51 AM
To: Mika Kiljunen
Subject: Re: [flexcoders] Changing
the wrongLengthError in a DateValidator
Mika,
thx, this is a very helpful one.
Today I ran into another one, I was trying to
access the field
attribute of a validator inside the class, got an
undefined all the
time. The docs states that the field propery is
not to be set in
ActionScript, is it not accessable at all?
app.mxml:
<MyOwnValidator field="model.bla"
/>
inside of MyOwnValidator.as:
class MyOwnValidator extens
mx.validators.EmailValidator
{
public var myfield
= ??? ;
...
}
Cheers
Kai
MK> Oops, this is the problem I was trying to
answer to. Sorry folks about the
MK> previous post... :)
MK> Class MyDateValidator extends
mx.validators.DateValidator
MK> {
MK> public function
validationError(errorCode:String,
MK> defaultMessage:String,subfield:String):Void
MK> {
MK>
If (errorCode == “wrongLength”)
MK>
defaultMessage = yourTranslatedMessage;
MK>
super.validationError(errorCode, defaultMessage, subfield);
MK> }
MK> }
MK> Only thing you need to do is catch the
wrongLength error and re-write the
MK> error message yourself.
MK> -Mika
MK> -----Original Message-----
MK> From: [email protected]
MK> [mailto:[email protected]]
On
MK> Behalf Of Kai König
MK> Sent: 17. elokuuta 2005 16:56
MK> To: [email protected]
MK> Subject: [flexcoders] Changing the
wrongLengthError in a DateValidator
MK> Hi all,
MK> another validator-related question:
MK> Having to validate for a date using a
DateValidator, the requirements
MK> are to just deliver one validation message
if the validation fails.
MK> Following the concept, I'd have to add a
long list of attributes to my
MK> validator call, as in:
MK> <mx:DateValidator ...
invalidCharError="blabla"
MK>
invalidFormatCharsError="blabla" ... />
MK> So we thought it might be nice to subclass
the DataValidator and to
MK> define a defaultErrorMessage which we can
pass into our own validator
MK> class and internally, the class is
responsible to overwrite the values
MK> of the pre-defined errors.
MK> Works quite good, BUT doesn't work for
wrongLengthError. The docs
MK> state:
>>Error message when the length of the date
doesn't match that of the
>>inputFormat. Default is "Please type
the date in the format
>><i>inputFormat</i>.".
MK> That means the default error might be
something like:
MK> "Please...format mm/dd/yyyy"
MK> As far as I understand, I'd expect to be
able to overwrite the default
MK> with anything I like, but regardless to
what I set the value for
MK> wrongLengthError, Flex always adds the
value of inputFormat to my
MK> error message - I end up with something
like
MK> "This is my errortext and I want you
to type it correct mm/dd/yyyy"
MK> This is especially annoying with localized
error messages in which the
MK> inputFormat has to be at another place
within the error message by
MK> grammar: "Bitte nutzen Sie das Format
dd.mm.yyyy in diesem Feld".
MK> Is there a way to get rid of the automatic
concatenation of the
MK> inputFormat within the wrongLengthError of
this validator?
MK> Cheers
MK> Kai
MK> --
MK> Flexcoders Mailing List
MK> FAQ:
MK> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
MK> Search Archives:
MK> http://www.mail-archive.com/flexcoders%40yahoogroups.com
MK> Yahoo! Groups Links
MK> --
MK> Flexcoders Mailing List
MK> FAQ:
MK> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
MK> Search Archives:
MK> http://www.mail-archive.com/flexcoders%40yahoogroups.com
MK> Yahoo! Groups Links
--
Best regards,
Kai
mailto:[EMAIL PROTECTED]
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS