myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: ExtVal: Validating an objects attributes if at least one these has a value
Date Thu, 01 Jul 2010 14:58:31 GMT
hi tom,

in this special case the usage of @SkipValidation wouldn't lead to a nice
solution.

in case of bv + extval: there is a new add-on [1] for bv based
multi-field-validation.
however, also with this new prototype you would need group-validation (for
this special case) to bypass the constraints hosted at the targets of the
value-bindings.

regards,
gerhard

[1]
http://os890.blogspot.com/2010/06/multi-field-form-validation-with-jsr.html

http://www.irian.at

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

Professional Support for Apache MyFaces



2010/7/1 <mynewsgroups@arcor.de>

> Hi at all,
>
> I have the following use case simplified with an object 'Address' including
> zip, city and so on using BeanValidation:
>
> public class Address {
>
>  @NotNull(Create.class)
>  @Size(min=3, max=10)
>  private String zip;
>
>  @NotNull
>  @Size(min=3, max=50)
>  private String city;
>
> ...
> }
>
> This class should be used in two pages: for creating an address (both
> attributes need to be set, group=Create) and to find an address (city is
> sufficient for searching, group=default).
>
> In addition I want to reuse the address definition in pages to submit or
> search an order with both a home address and an optional invoice address.
> The problem is: if no value is entered into the fields for the invoice
> address, it should not be validated at all. If at least one field is filled,
> all constraints have to be validated, additionally considering groups to be
> used.
>
> I think with bean validation only this is not possible, that's why I guess
> I have to use ExtVal again but don't know where to start. A custom
> validation strategy would be a choice, perhaps @SkipValidation offers
> another way to go? Or can it be done even easier (settings remain unchanged:
> single class as central point for validation rules which is reusabe in
> different use cases, validation should take place in validation phase)?
>
> Can you give me some advice where to start?
>
> Thanks,
> Tom
>
>
>
> --
> Hotelbewertung: Bloß nicht die Katze im Sack kaufen bzw. den Floh auf der
> Matratze buchen -
> ob geschäftlich oder privat - erst das Hotel im Reise-Channel auf arcor.dechecken!
> http://www.arcor.de/rd/footer.hotel
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message