Return-Path: X-Original-To: apmail-tapestry-dev-archive@www.apache.org Delivered-To: apmail-tapestry-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05CA710A86 for ; Tue, 16 Apr 2013 02:51:58 +0000 (UTC) Received: (qmail 33501 invoked by uid 500); 16 Apr 2013 02:51:57 -0000 Delivered-To: apmail-tapestry-dev-archive@tapestry.apache.org Received: (qmail 33483 invoked by uid 500); 16 Apr 2013 02:51:57 -0000 Mailing-List: contact dev-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tapestry development" Delivered-To: mailing list dev@tapestry.apache.org Received: (qmail 33474 invoked by uid 99); 16 Apr 2013 02:51:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Apr 2013 02:51:57 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of hlship@gmail.com designates 209.85.210.44 as permitted sender) Received: from [209.85.210.44] (HELO mail-da0-f44.google.com) (209.85.210.44) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Apr 2013 02:51:50 +0000 Received: by mail-da0-f44.google.com with SMTP id z20so21653dae.3 for ; Mon, 15 Apr 2013 19:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=zrPtgfaXieYNlLxMWCcMt5sWesAeP3Vrv/4qrBhNCO8=; b=WHf5RVKdCpyVlgM83OHqdfy6PXT6Mp3mVblQ4ZTQFahOFDdpDl1UlmyvgksxEKd+ON ADgqzCWx4Y+l7xqhWBuodh5KC4SVznTe7EzntMzeMCrBrFaX4EvyGq9HxY/n3kWx5Ebj 5md5yytiz+qI9RS9Nvx5RYZ+N/podA8rmJhsa0SsLMtKXAtM/5Z/HlWbFEgUW1fiINSE ULc5gjatiJVrY89Ivb4Nit0jv3sJdQlq+lXthUzI2Nq0wfhScuSqkUNpfFFGmoqc/LA4 /+VFCbClsHuIaDCHIQa0cevYghOb+R5dX7hv08WkNKRKKx2WzphFrPrUisOn2vjbCg5L gcUA== MIME-Version: 1.0 X-Received: by 10.68.88.194 with SMTP id bi2mr546519pbb.12.1366080689418; Mon, 15 Apr 2013 19:51:29 -0700 (PDT) Received: by 10.70.15.1 with HTTP; Mon, 15 Apr 2013 19:51:29 -0700 (PDT) In-Reply-To: References: Date: Tue, 16 Apr 2013 03:51:29 +0100 Message-ID: Subject: Re: git commit: FIXED - TAP5-2101: BeanEditor should always provide a new BeanValidationContext (JSR-303) - apply Luca Menegus' patch with minor changes From: Howard Lewis Ship To: "dev@tapestry.apache.org" Content-Type: multipart/alternative; boundary=047d7b673c7a3a36af04da7172e5 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b673c7a3a36af04da7172e5 Content-Type: text/plain; charset=ISO-8859-1 looks like tests related to this change are failing on jenkins On Sunday, April 14, 2013, wrote: > Updated Branches: > refs/heads/master d3e9f1d95 -> cb95e2236 > > > FIXED - TAP5-2101: BeanEditor should always provide a new > BeanValidationContext (JSR-303) > - apply Luca Menegus' patch with minor changes > > > Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo > Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/cb95e223 > Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/cb95e223 > Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/cb95e223 > > Branch: refs/heads/master > Commit: cb95e2236873b497211427e89f96e54282919e19 > Parents: d3e9f1d > Author: kaosko > > Authored: Sat Apr 13 22:11:33 2013 -0700 > Committer: kaosko > > Committed: Sat Apr 13 22:11:33 2013 -0700 > > ---------------------------------------------------------------------- > .../TapestryBeanValidationIntegrationTests.java | 14 +++++ > .../org/example/testapp/entities/ComplexBean.java | 44 +++++++++++++++ > .../testapp/entities/SomeOtherSimpleBean.java | 21 +++++++ > .../example/testapp/entities/SomeSimpleBean.java | 21 +++++++ > .../org/example/testapp/pages/ComplexBeanDemo.java | 14 +++++ > .../src/test/webapp/ComplexBeanDemo.tml | 19 ++++++ > tapestry-beanvalidator/src/test/webapp/Index.tml | 3 + > .../tapestry5/corelib/components/BeanEditor.java | 24 ++++---- > 8 files changed, 148 insertions(+), 12 deletions(-) > ---------------------------------------------------------------------- > > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java > b/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java > index 29b50bf..248c24e 100644 > --- > a/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java > +++ > b/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java > @@ -216,4 +216,18 @@ public class TapestryBeanValidationIntegrationTests > extends SeleniumTestCase > assertTextPresent("Login Name size must be between 7 and 10", > "Login Name must match \"[0-9]+\""); > } > > + @Test > + public void beaneditor_validation() throws Exception > + { > + openLinks("ComplexBean Demo"); > + > + // Test JSR-303 validator > + > + clickAndWait(SUBMIT); > + > + assertTextPresent("Simple Not Null Property may not be null", > + "Min Value must be greater than or equal to 6", "Not Null > String may not be null"); > + } > + > + > } > \ No newline at end of file > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/ComplexBean.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/ComplexBean.java > b/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/ComplexBean.java > new file mode 100644 > index 0000000..beaa840 > --- /dev/null > +++ > b/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/ComplexBean.java > @@ -0,0 +1,44 @@ > +package org.example.testapp.entities; > + > +import javax.validation.constraints.NotNull; > + > +public class ComplexBean > +{ > + > + private SomeSimpleBean someSimpleBean; > + private SomeOtherSimpleBean someOtherSimpleBean; > + > + @NotNull > + private String simpleNotNullProperty; > + > + public SomeSimpleBean getSomeSimpleBean() > + { > + return someSimpleBean; > + } > + > + public void setSomeSimpleBean(SomeSimpleBean someSimpleBean) > + { > + this.someSimpleBean = someSimpleBean; > + } > + > + public SomeOtherSimpleBean getSomeOtherSimpleBean() > + { > + return someOtherSimpleBean; > + } > + > + public void setSomeOtherSimpleBean(SomeOtherSimpleBean > someOtherSimpleBean) > + { > + this.someOtherSimpleBean = someOtherSimpleBean; > + } > + > + public String getSimpleNotNullProperty() > + { > + return simpleNotNullProperty; > + } > + > + public void setSimpleNotNullProperty(String simpleNotNullProperty) > + { > + this.simpleNotNullProperty = simpleNotNullProperty; > + } > + > +} > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeOtherSimpleBean.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeOtherSimpleBean.java > b/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeOtherSimpleBean.java > new file mode 100644 > index 0000000..9a262f3 > --- /dev/null > +++ > b/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeOtherSimpleBean.java > @@ -0,0 +1,21 @@ > +package org.example.testapp.entities; > + > +import javax.validation.constraints.NotNull; > + > +public class SomeOtherSimpleBean > +{ > + > + @NotNull > + private String notNullString; > + > + public String getNotNullString() > + { > + return notNullString; > + } > + > + public void setNotNullString(String notNullString) > + { > + this.notNullString = notNullString; > + } > + > +} > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeSimpleBean.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeSimpleBean.java > b/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeSimpleBean.java > new file mode 100644 > index 0000000..1564112 > --- /dev/null > +++ > b/tapestry-beanvalidator/src/test/java/org/example/testapp/entities/SomeSimpleBean.java > @@ -0,0 +1,21 @@ > +package org.example.testapp.entities; > + > +import javax.validation.constraints.Min; > + > +public class SomeSimpleBean > +{ > + > + @Min(6) > + private int minValue; > + > + public int getMinValue() > + { > + return minValue; > + } > + > + public void setMinValue(int minValue) > + { > + this.minValue = minValue; > + } > + > +} > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/ComplexBeanDemo.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/ComplexBeanDemo.java > b/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/ComplexBeanDemo.java > new file mode 100644 > index 0000000..f7b2623 > --- /dev/null > +++ > b/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/ComplexBeanDemo.java > @@ -0,0 +1,14 @@ > +package org.example.testapp.pages; > + > +import org.apache.tapestry5.annotations.Persist; > +import org.apache.tapestry5.annotations.Property; > +import org.example.testapp.entities.ComplexBean; > + > +public class ComplexBeanDemo > +{ > + > + @Property > + @Persist > + private ComplexBean complexBean; > + > +} > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/webapp/ComplexBeanDemo.tml > ---------------------------------------------------------------------- > diff --git a/tapestry-beanvalidator/src/test/webapp/ComplexBeanDemo.tml > b/tapestry-beanvalidator/src/test/webapp/ComplexBeanDemo.tml > new file mode 100644 > index 0000000..fd20eab > --- /dev/null > +++ b/tapestry-beanvalidator/src/test/webapp/ComplexBeanDemo.tml > @@ -0,0 +1,19 @@ > + > + > + > + > + > +
> + > + > +
> + > + > +
> + > + > +
> + > +
> + > + > \ No newline at end of file > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-beanvalidator/src/test/webapp/Index.tml > ---------------------------------------------------------------------- > diff --git a/tapestry-beanvalidator/src/test/webapp/Index.tml > b/tapestry-beanvalidator/src/test/webapp/Index.tml > index da8978e..0970c96 100644 > --- a/tapestry-beanvalidator/src/test/webapp/Index.tml > +++ b/tapestry-beanvalidator/src/test/webapp/Index.tml > @@ -24,6 +24,9 @@ >
  • > OnPrepare > Demo >
  • > +
  • > + ComplexBean > Demo > +
  • > > > > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cb95e223/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java > b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java > index 1d7ed6c..94c37b9 100644 > --- > a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java > +++ > b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java > @@ -166,6 +166,8 @@ public class BeanEditor > */ > private Object cachedObject; > > + private BeanValidationContext originalBeanValidationContext; > + > // Needed for testing as well > > public Object getObject() > @@ -213,10 +215,6 @@ public class BeanEditor > PlasticUtils.toTypeName(model.getBeanType()), > resources.getCompleteId(), ex); > throw new TapestryException(message, > resources.getLocation(), ex); > } > - > - // If 'object' parameter is bound to a null-value > BeanValidationContext is empty. > - // This prevents JSR-303 javascript validators to be rendered > properly . > - refreshBeanValidationContext(); > } > > BeanEditContext context = new BeanEditContext() > @@ -235,20 +233,22 @@ public class BeanEditor > cachedObject = object; > > environment.push(BeanEditContext.class, context); > + // Always provide a new BeanValidationContext > + originalBeanValidationContext = > environment.push(BeanValidationContext.class, > + new BeanValidationContextImpl(object)); > + > } > > void cleanupEnvironment() > { > environment.pop(BeanEditContext.class); > - } > - > - private void refreshBeanValidationContext() > - { > - if (environment.peek(BeanValidationContext.class) != null) > + environment.pop(BeanValidationContext.class); > + // Restore the original BeanValidationContext as it might still > be useful to the enclosing > + // form > + if (originalBeanValidationContext != null) > { > - environment.pop(BeanValidationContext.class); > - > - environment.push(BeanValidationContext.class, new > BeanValidationContextImpl(object)); > + environment.push(BeanValidationContext.class, > originalBeanValidationContext); > + originalBeanValidationContext = null; > } > } > > > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --047d7b673c7a3a36af04da7172e5--