You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by dr...@apache.org on 2009/10/22 22:34:08 UTC

svn commit: r828840 - in /tapestry/tapestry5/trunk/tapestry-core/src/main: java/org/apache/tapestry5/corelib/components/ java/org/apache/tapestry5/services/ resources/org/apache/tapestry5/corelib/components/

Author: drobiazko
Date: Thu Oct 22 20:34:06 2009
New Revision: 828840

URL: http://svn.apache.org/viewvc?rev=828840&view=rev
Log:
TAP5-895: Tracking issue for Tapestry/JSR-303 integration

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java   (with props)
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditForm.tml

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=828840&r1=828839&r2=828840&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java Thu Oct 22 20:34:06 2009
@@ -158,6 +158,14 @@
      */
     @Parameter
     private String validationId;
+    
+    /**
+     * Object to validate during the form submission process. The value of this parameter is pushed as a 
+     * {@link org.apache.tapestry5.services.BeanValidationContext} into the environment. This parameter should
+     * only be used in combination with the Bean Validation Library.
+     */
+    @Parameter
+    private Object validate;
 
     @Inject
     private Logger logger;
@@ -215,6 +223,11 @@
     {
         return resources.getId();
     }
+    
+    Object defaultValidate()
+    {
+        return resources.getContainer();
+    }
 
     public ValidationTracker getDefaultTracker()
     {
@@ -355,6 +368,12 @@
 
         environment.push(ValidationTracker.class, tracker);
         environment.push(FormSupport.class, formSupport);
+        environment.push(BeanValidationContext.class, new BeanValidationContext(){
+
+            public Object getObject()
+            {
+                return validate;
+            }});
 
         Heartbeat heartbeat = new HeartbeatImpl();
 
@@ -416,6 +435,8 @@
             // stored back into the session.
 
             tracker = environment.pop(ValidationTracker.class);
+            
+            environment.pop(BeanValidationContext.class);
         }
     }
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java?rev=828840&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java Thu Oct 22 20:34:06 2009
@@ -0,0 +1,27 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry5.services;
+
+/**
+ * Defines a context for validating beans.
+ * 
+ * @since 5.2.0.0
+ */
+public interface BeanValidationContext
+{
+    /**
+     * Return the object to validate.
+     */
+    Object getObject();
+}

Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/BeanValidationContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditForm.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditForm.tml?rev=828840&r1=828839&r2=828840&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditForm.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditForm.tml Thu Oct 22 20:34:06 2009
@@ -1,4 +1,4 @@
-<form t:id="form"
+<form t:id="form" validate="object"
       xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
     <t:errors/>