Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 41470 invoked from network); 1 Jul 2010 15:00:20 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Jul 2010 15:00:20 -0000 Received: (qmail 75062 invoked by uid 500); 1 Jul 2010 15:00:19 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 75024 invoked by uid 500); 1 Jul 2010 15:00:19 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 75016 invoked by uid 99); 1 Jul 2010 15:00:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jul 2010 15:00:19 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gerhard.petracek@gmail.com designates 74.125.82.46 as permitted sender) Received: from [74.125.82.46] (HELO mail-ww0-f46.google.com) (74.125.82.46) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jul 2010 15:00:13 +0000 Received: by wwi18 with SMTP id 18so623260wwi.27 for ; Thu, 01 Jul 2010 07:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=b7uybBGAAbtJBRtz4YiQDj+xuNQPm+/5O4k3c6zCXwg=; b=I7d2nBexl2qprfqz1qht3rTnm2DMl2FU1/nD/r9B+VWONPK0DOcITyO5knKIsU3hFj WK/1i+WG8b/qRD1PuIvLIX71R63W5A+otBpT3SogAIrAPHHXbDKcOSo9YV6i92mtfXv5 X+Xt1zkl6XTOmDJy8woLYCLaSJLzjKst9t8ak= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=XF49y1OpOxpeYysby6RqlOhFTeoyyg7KBKsQg/KgzPBM7IjT9+zkRiEe1tX89QsJo8 2otJUiwqpSz23P4vZrscG+r6ri3zMJ/zQkqh6ClyJEJXBEAeeqbOMWKin+ixrfCZzKcU HEXBfeAK+GsK4Uix2EuJ/GGEzZr8kpi9atvOM= Received: by 10.239.131.211 with SMTP id 19mr764972hbo.125.1277996332228; Thu, 01 Jul 2010 07:58:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.140.97 with HTTP; Thu, 1 Jul 2010 07:58:31 -0700 (PDT) In-Reply-To: <33178204.1277993317903.JavaMail.ngmail@webmail17.arcor-online.net> References: <33178204.1277993317903.JavaMail.ngmail@webmail17.arcor-online.net> From: Gerhard Petracek Date: Thu, 1 Jul 2010 16:58:31 +0200 Message-ID: Subject: Re: ExtVal: Validating an objects attributes if at least one these has a value To: MyFaces Discussion Content-Type: multipart/alternative; boundary=001485f49a7e682234048a54b582 X-Virus-Checked: Checked by ClamAV on apache.org --001485f49a7e682234048a54b582 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 > Hi at all, > > I have the following use case simplified with an object 'Address' includi= ng > zip, city and so on using BeanValidation: > > public class Address { > > @NotNull(Create.class) > @Size(min=3D3, max=3D10) > private String zip; > > @NotNull > @Size(min=3D3, max=3D50) > private String city; > > ... > } > > This class should be used in two pages: for creating an address (both > attributes need to be set, group=3DCreate) and to find an address (city i= s > sufficient for searching, group=3Ddefault). > > 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 fill= ed, > 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 gues= s > 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 unchang= ed: > 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=DF nicht die Katze im Sack kaufen bzw. den Floh auf d= er > Matratze buchen - > ob gesch=E4ftlich oder privat - erst das Hotel im Reise-Channel auf arcor= .dechecken! > http://www.arcor.de/rd/footer.hotel > > --001485f49a7e682234048a54b582--