You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Gerhard Petracek <ge...@gmail.com> on 2009/12/01 21:44:35 UTC

Re: [EXTVal] Validators wihtout implicit required validations

hi markus,

i introduced marker annotations [1] so that you can easily mark validation
strategies which are aware of empty- and null-values.
i committed the changes as well as test-cases. there will be a new
(milestone) version quite soon.

regards,
gerhard

[1] http://issues.apache.org/jira/browse/EXTVAL-74

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2009/11/30 Gerhard Petracek <ge...@gmail.com>

> short addition:
>
> i see your point and i’ll change that.
> for now: my previous post contains a list of simple solutions you can use.
>
> regards,
> gerhard
>
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
> 2009/11/30 Gerhard Petracek <ge...@gmail.com>
>
> hi,
>>
>> it's a bit different.
>> the parameter mentioned by jakob is a jsf 2.0 parameter especially for the
>> jsr 303 integration.
>> if you set it to true, the not-null constraint will be interpreted like
>> required (= true).
>> extval uses it in an abstract class in a similar way. that means: you just
>> have to use it to explicitly deactivate the behavior described above.
>> it's automatically available for custom validation interceptors. an
>> internal example is the validation interceptor of the bean-validation module
>> (which allows to use jsr 303 with all jsf versions).
>>
>> the property validation module of the next release (as well as the
>> available milestone) overrides this new default behavior so that an empty
>> field doesn't lead to a null value for validation (due to backward
>> compatibility reasons). however, you can easily customize this behavior.
>>
>> back to the original question:
>>
>> extval just delegates to the (configured) jsf length validator. so
>> basically the behavior depends on the implementation you are using in your
>> application.
>>
>> in this case the default implementation throws an exception because it
>> isn't aware of empty values. to change this behavior you can:
>> - register your custom jsf-length-validator implementation (see:
>> javax.faces.Length) which handles it as you expect it (that's plain jsf)
>> or
>> - replace the default extval validation strategy for @Length to ignore
>> empty values
>> or
>> - implement your custom extval annotation
>>
>> all 3 possibilities are quite easy.
>>
>> regards,
>> gerhard
>>
>> http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>>
>>
>> 2009/11/30 Jakob Korherr <ja...@gmail.com>
>>
>> Hi Markus,
>>>
>>> Take a look at the
>>> javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
>>> config parameter in web.xml.
>>>
>>> Setting this to true will cause that your property "input" will be null,
>>> if
>>> the user submits an empty field and thus @Length will not be processed.
>>>
>>> Also take a look at http://jsfatwork.irian.at/semistatic/jsf.html,
>>> chapter
>>> 2.12 Validierung fur further information. It's written in german, but I
>>> assume you're from Germany...
>>>
>>> Regards
>>>
>>> Jakob Korherr
>>>
>>>
>>> 2009/11/30 Dreher, Markus <M....@dzbw.de>
>>>
>>> > Hi all,
>>> >
>>> > i want to validate a field only when the user filled it out.
>>> >
>>> > It's not a reuqired field, but when it is filled out, the input should
>>> > be at least for example 3 digits.
>>> >
>>> >    @Length(minimum=3, maximum = 60)
>>> >    private String input;
>>> >
>>> > With @Length this leads to a required field.
>>> >
>>> > Do i miss something?
>>> >
>>> > Regards,
>>> >
>>> > Markus
>>> >
>>> >
>>> >
>>>
>>
>>
>

AW: [EXTVal] Validators wihtout implicit required validations

Posted by "Dreher, Markus" <M....@dzbw.de>.
Hi Gerhard,

thanks for your answers. I checked out the trunk and it's working as i expect it.
I forgot to mention that i'm using facelets and trinidad, but the component support handles this great.


Regards,

Markus

-----Ursprüngliche Nachricht-----
Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com] 
Gesendet: Dienstag, 1. Dezember 2009 21:45
An: MyFaces Discussion
Betreff: Re: [EXTVal] Validators wihtout implicit required validations

hi markus,

i introduced marker annotations [1] so that you can easily mark validation
strategies which are aware of empty- and null-values.
i committed the changes as well as test-cases. there will be a new
(milestone) version quite soon.

regards,
gerhard

[1] http://issues.apache.org/jira/browse/EXTVAL-74

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2009/11/30 Gerhard Petracek <ge...@gmail.com>

> short addition:
>
> i see your point and i'll change that.
> for now: my previous post contains a list of simple solutions you can use.
>
> regards,
> gerhard
>
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
> 2009/11/30 Gerhard Petracek <ge...@gmail.com>
>
> hi,
>>
>> it's a bit different.
>> the parameter mentioned by jakob is a jsf 2.0 parameter especially for the
>> jsr 303 integration.
>> if you set it to true, the not-null constraint will be interpreted like
>> required (= true).
>> extval uses it in an abstract class in a similar way. that means: you just
>> have to use it to explicitly deactivate the behavior described above.
>> it's automatically available for custom validation interceptors. an
>> internal example is the validation interceptor of the bean-validation module
>> (which allows to use jsr 303 with all jsf versions).
>>
>> the property validation module of the next release (as well as the
>> available milestone) overrides this new default behavior so that an empty
>> field doesn't lead to a null value for validation (due to backward
>> compatibility reasons). however, you can easily customize this behavior.
>>
>> back to the original question:
>>
>> extval just delegates to the (configured) jsf length validator. so
>> basically the behavior depends on the implementation you are using in your
>> application.
>>
>> in this case the default implementation throws an exception because it
>> isn't aware of empty values. to change this behavior you can:
>> - register your custom jsf-length-validator implementation (see:
>> javax.faces.Length) which handles it as you expect it (that's plain jsf)
>> or
>> - replace the default extval validation strategy for @Length to ignore
>> empty values
>> or
>> - implement your custom extval annotation
>>
>> all 3 possibilities are quite easy.
>>
>> regards,
>> gerhard
>>
>> http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>>
>>
>> 2009/11/30 Jakob Korherr <ja...@gmail.com>
>>
>> Hi Markus,
>>>
>>> Take a look at the
>>> javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
>>> config parameter in web.xml.
>>>
>>> Setting this to true will cause that your property "input" will be null,
>>> if
>>> the user submits an empty field and thus @Length will not be processed.
>>>
>>> Also take a look at http://jsfatwork.irian.at/semistatic/jsf.html,
>>> chapter
>>> 2.12 Validierung fur further information. It's written in german, but I
>>> assume you're from Germany...
>>>
>>> Regards
>>>
>>> Jakob Korherr
>>>
>>>
>>> 2009/11/30 Dreher, Markus <M....@dzbw.de>
>>>
>>> > Hi all,
>>> >
>>> > i want to validate a field only when the user filled it out.
>>> >
>>> > It's not a reuqired field, but when it is filled out, the input should
>>> > be at least for example 3 digits.
>>> >
>>> >    @Length(minimum=3, maximum = 60)
>>> >    private String input;
>>> >
>>> > With @Length this leads to a required field.
>>> >
>>> > Do i miss something?
>>> >
>>> > Regards,
>>> >
>>> > Markus
>>> >
>>> >
>>> >
>>>
>>
>>
>