You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Adam Winer <aw...@gmail.com> on 2007/05/22 19:55:59 UTC
[TRINIDAD] LengthValidator fixes
The Trinidad subclass of LengthValidator needs some work.
Changes I plan to make - feedback appreciated:
- The messages are copied from the LongRangeValidator, so
we say "Enter a value greater than or equal to 5" instead
of "Enter a value of 5 or more characters". (I'll use the latter)
- If min and max are the same, we don't have a custom message,
so you'd get something like "Enter a value between 5 and 5
characters". Looks silly. So, in addition to
LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
- The override of Validate assumes the value is a Number!, and
lots of Javadoc is cut-and-pasted from LongRangeValidator,
it would seem... Thankfully, there's an instanceof check,
so no ClassCastExceptions but this code has to just be broken...
-- Adam
Re: [TRINIDAD] LengthValidator fixes
Posted by Blake Sullivan <bl...@oracle.com>.
Adam Winer wrote:
> On 5/22/07, Blake Sullivan <bl...@oracle.com> wrote:
>> Adam Winer wrote:
>> > The Trinidad subclass of LengthValidator needs some work.
>> > Changes I plan to make - feedback appreciated:
>> >
>> > - The messages are copied from the LongRangeValidator, so
>> > we say "Enter a value greater than or equal to 5" instead
>> > of "Enter a value of 5 or more characters". (I'll use the latter)
>> Do surrogates count as a character?
>
> At this time, they count as a character. That's bogus,
> but is an issue in the JSF implementation. (It's
> also an issue that is a nightmare for our JS code.)
As long as we suck consistently between the client and the server. :)
-- Blake
>
> -- Adam
>
>
>>
>> -- Blake Sullivan
>>
>> >
>> > - If min and max are the same, we don't have a custom message,
>> > so you'd get something like "Enter a value between 5 and 5
>> > characters". Looks silly. So, in addition to
>> > LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
>> >
>> > - The override of Validate assumes the value is a Number!, and
>> > lots of Javadoc is cut-and-pasted from LongRangeValidator,
>> > it would seem... Thankfully, there's an instanceof check,
>> > so no ClassCastExceptions but this code has to just be broken...
>> >
>> > -- Adam
>>
>>
Re: [TRINIDAD] LengthValidator fixes
Posted by Adam Winer <aw...@gmail.com>.
On 5/22/07, Blake Sullivan <bl...@oracle.com> wrote:
> Adam Winer wrote:
> > The Trinidad subclass of LengthValidator needs some work.
> > Changes I plan to make - feedback appreciated:
> >
> > - The messages are copied from the LongRangeValidator, so
> > we say "Enter a value greater than or equal to 5" instead
> > of "Enter a value of 5 or more characters". (I'll use the latter)
> Do surrogates count as a character?
At this time, they count as a character. That's bogus,
but is an issue in the JSF implementation. (It's
also an issue that is a nightmare for our JS code.)
-- Adam
>
> -- Blake Sullivan
>
> >
> > - If min and max are the same, we don't have a custom message,
> > so you'd get something like "Enter a value between 5 and 5
> > characters". Looks silly. So, in addition to
> > LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
> >
> > - The override of Validate assumes the value is a Number!, and
> > lots of Javadoc is cut-and-pasted from LongRangeValidator,
> > it would seem... Thankfully, there's an instanceof check,
> > so no ClassCastExceptions but this code has to just be broken...
> >
> > -- Adam
>
>
Re: [TRINIDAD] LengthValidator fixes
Posted by Blake Sullivan <bl...@oracle.com>.
Adam Winer wrote:
> The Trinidad subclass of LengthValidator needs some work.
> Changes I plan to make - feedback appreciated:
>
> - The messages are copied from the LongRangeValidator, so
> we say "Enter a value greater than or equal to 5" instead
> of "Enter a value of 5 or more characters". (I'll use the latter)
Do surrogates count as a character?
-- Blake Sullivan
>
> - If min and max are the same, we don't have a custom message,
> so you'd get something like "Enter a value between 5 and 5
> characters". Looks silly. So, in addition to
> LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
>
> - The override of Validate assumes the value is a Number!, and
> lots of Javadoc is cut-and-pasted from LongRangeValidator,
> it would seem... Thankfully, there's an instanceof check,
> so no ClassCastExceptions but this code has to just be broken...
>
> -- Adam
Re: [TRINIDAD] LengthValidator fixes
Posted by Gabrielle Crawford <ga...@oracle.com>.
+1 to all three.
On 5/22/2007 10:55 AM, Adam Winer wrote:
> The Trinidad subclass of LengthValidator needs some work.
> Changes I plan to make - feedback appreciated:
>
> - The messages are copied from the LongRangeValidator, so
> we say "Enter a value greater than or equal to 5" instead
> of "Enter a value of 5 or more characters". (I'll use the latter)
>
> - If min and max are the same, we don't have a custom message,
> so you'd get something like "Enter a value between 5 and 5
> characters". Looks silly. So, in addition to
> LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
>
> - The override of Validate assumes the value is a Number!, and
> lots of Javadoc is cut-and-pasted from LongRangeValidator,
> it would seem... Thankfully, there's an instanceof check,
> so no ClassCastExceptions but this code has to just be broken...
>
> -- Adam
Re: [TRINIDAD] LengthValidator fixes
Posted by Adam Winer <aw...@gmail.com>.
On 5/22/07, Matthias Wessendorf <ma...@apache.org> wrote:
> On 5/22/07, Adam Winer <aw...@gmail.com> wrote:
> > The Trinidad subclass of LengthValidator needs some work.
> > Changes I plan to make - feedback appreciated:
> >
> > - The messages are copied from the LongRangeValidator, so
> > we say "Enter a value greater than or equal to 5" instead
> > of "Enter a value of 5 or more characters". (I'll use the latter)
>
> yup
>
> > - If min and max are the same, we don't have a custom message,
> > so you'd get something like "Enter a value between 5 and 5
> > characters". Looks silly. So, in addition to
> > LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
>
> indeed
>
> > - The override of Validate assumes the value is a Number!, and
> > lots of Javadoc is cut-and-pasted from LongRangeValidator,
> > it would seem... Thankfully, there's an instanceof check,
> > so no ClassCastExceptions but this code has to just be broken...
>
> LongRangeVali ? or LengthVali (see subject)
> the myfaces LengthVali does:
>
> int length = value instanceof String ?
> ((String)value).length() : value.toString().length();
I meant the Trinidad subclass of javax.faces.validator.LengthValidator -
sorry for the confusion. The MyFaces Core LengthValidator
is fine, though I'd just write that line as:
value.toString().length();
... as String.toString() is a noop. I basically never cast to
String, I always call toString() if the value isn't null.
-- Adam
Re: [TRINIDAD] LengthValidator fixes
Posted by Matthias Wessendorf <ma...@apache.org>.
On 5/22/07, Adam Winer <aw...@gmail.com> wrote:
> The Trinidad subclass of LengthValidator needs some work.
> Changes I plan to make - feedback appreciated:
>
> - The messages are copied from the LongRangeValidator, so
> we say "Enter a value greater than or equal to 5" instead
> of "Enter a value of 5 or more characters". (I'll use the latter)
yup
> - If min and max are the same, we don't have a custom message,
> so you'd get something like "Enter a value between 5 and 5
> characters". Looks silly. So, in addition to
> LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT.
indeed
> - The override of Validate assumes the value is a Number!, and
> lots of Javadoc is cut-and-pasted from LongRangeValidator,
> it would seem... Thankfully, there's an instanceof check,
> so no ClassCastExceptions but this code has to just be broken...
LongRangeVali ? or LengthVali (see subject)
the myfaces LengthVali does:
int length = value instanceof String ?
((String)value).length() : value.toString().length();
>
> -- Adam
>
--
Matthias Wessendorf
further stuff:
blog: http://matthiaswessendorf.wordpress.com/
mail: matzew-at-apache-dot-org