tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [3/3] tapestry-5 git commit: Finish backing out the validationId changes (commit ef0d1448aca3bca3ed4f8aea6fbedd6b77438fcc)
Date Tue, 07 Apr 2015 23:39:06 GMT
Finish backing out the validationId changes (commit ef0d1448aca3bca3ed4f8aea6fbedd6b77438fcc)


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/93d06899
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/93d06899
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/93d06899

Branch: refs/heads/master
Commit: 93d06899a95161f3c27e3e1b5aaa8dfa83f36f7f
Parents: 22bd2c1
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Tue Apr 7 16:26:29 2015 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Tue Apr 7 16:26:29 2015 -0700

----------------------------------------------------------------------
 .../corelib/components/BeanEditor.java          | 18 ++---
 .../tapestry5/corelib/components/Form.java      |  4 +-
 .../corelib/pages/PropertyEditBlocks.java       | 83 +++++---------------
 .../internal/BeanValidationContext.java         | 20 ++---
 .../internal/BeanValidationContextImpl.java     | 18 ++---
 5 files changed, 39 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/93d06899/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 c44c9fa..45a9711 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
@@ -33,13 +33,11 @@ import org.apache.tapestry5.services.BeanModelSource;
 import org.apache.tapestry5.services.Environment;
 import org.apache.tapestry5.services.FormSupport;
 
-import java.util.UUID;
-
 /**
  * A component that generates a user interface for editing the properties of a bean. This
is the central component of
  * the {@link BeanEditForm}, and utilizes a {@link PropertyEditor} for much of its functionality.
This component places
  * a {@link BeanEditContext} into the environment.
- *
+ * 
  * @tapestrydoc
  */
 @SupportsInformalParameters
@@ -181,8 +179,6 @@ public class BeanEditor
         formSupport.storeAndExecute(this, CLEANUP_ENVIRONMENT);
     }
 
-    private String validationId;
-
     /**
      * Used to initialize the model if necessary, to instantiate the object being edited
if necessary, and to push the
      * BeanEditContext into the environment.
@@ -206,7 +202,8 @@ public class BeanEditor
             try
             {
                 object = model.newInstance();
-            } catch (Exception ex)
+            }
+            catch (Exception ex)
             {
                 String message = String.format("Exception instantiating instance of %s (for
component '%s'): %s",
                         PlasticUtils.toTypeName(model.getBeanType()), resources.getCompleteId(),
ex);
@@ -214,18 +211,13 @@ public class BeanEditor
             }
         }
 
-        // Set to a new value on each request; the value lasts until the end of the request.
-        if (validationId == null) {
-            validationId = UUID.randomUUID().toString();
-        }
-
         BeanEditContext context = new BeanEditContextImpl(model.getBeanType());
 
         cachedObject = object;
 
         environment.push(BeanEditContext.class, context);
         // TAP5-2101: Always provide a new BeanValidationContext
-        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(object,
validationId));
+        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(object));
     }
 
     void cleanupEnvironment()
@@ -236,7 +228,7 @@ public class BeanEditor
 
     // For testing
     void inject(ComponentResources resources, PropertyOverrides overrides, BeanModelSource
source,
-                Environment environment)
+            Environment environment)
     {
         this.resources = resources;
         this.overrides = overrides;

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/93d06899/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
index 6147565..0102260 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
@@ -353,7 +353,7 @@ public class Form implements ClientElement, FormValidationControl
         resources.triggerEvent(EventConstants.PREPARE, context, null);
 
         // Push BeanValidationContext only after the container had a chance to prepare
-        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate,
null));
+        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
 
         // Save the form element for later, in case we want to write an encoding
         // type attribute.
@@ -509,7 +509,7 @@ public class Form implements ClientElement, FormValidationControl
                     return true;
             }
 
-            environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate,
null));
+            environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
 
             didPushBeanValidationContext = true;
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/93d06899/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
index 2013319..19326cc 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
@@ -19,7 +19,6 @@ import org.apache.tapestry5.ValueEncoder;
 import org.apache.tapestry5.annotations.Component;
 import org.apache.tapestry5.annotations.Environmental;
 import org.apache.tapestry5.corelib.components.*;
-import org.apache.tapestry5.internal.BeanValidationContext;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
 import org.apache.tapestry5.services.BeanBlockContribution;
@@ -40,96 +39,56 @@ public class PropertyEditBlocks
     @Environmental
     private PropertyEditContext context;
 
-    @Environmental
-    private BeanValidationContext validationContext;
-
-    public String getValidationId()
-    {
-        return validationContext.getEditorValidationId() + "-" + context.getPropertyId();
-    }
-
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "translate=prop:textFieldTranslator",
-                    "validate=prop:textFieldValidator",
-                    "validationId=validationId",
-                    "clientId=prop:context.propertyId",
-                    "annotationProvider=context",
+            parameters = {"value=context.propertyValue", "label=prop:context.label",
+                    "translate=prop:textFieldTranslator", "validate=prop:textFieldValidator",
+                    "clientId=prop:context.propertyId", "annotationProvider=context",
                     "ensureClientIdUnique=true"})
     private TextField textField;
 
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "translate=prop:numberFieldTranslator",
-                    "validate=prop:numberFieldValidator",
-                    "validationId=validationId",
-                    "clientId=prop:context.propertyId",
-                    "annotationProvider=context",
+            parameters = {"value=context.propertyValue", "label=prop:context.label",
+                    "translate=prop:numberFieldTranslator", "validate=prop:numberFieldValidator",
+                    "clientId=prop:context.propertyId", "annotationProvider=context",
                     "ensureClientIdUnique=true"})
     private TextField numberField;
 
 
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "encoder=valueEncoderForProperty",
-                    "validationId=validationId",
-                    "model=selectModelForProperty",
-                    "validate=prop:selectValidator",
-                    "clientId=prop:context.propertyId",
-                    "ensureClientIdUnique=true"})
+            parameters = {"value=context.propertyValue", "label=prop:context.label", "encoder=valueEncoderForProperty",
+                    "model=selectModelForProperty", "validate=prop:selectValidator",
+                    "clientId=prop:context.propertyId", "ensureClientIdUnique=true"})
     private Select select;
 
     @SuppressWarnings("unused")
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "validationId=validationId",
-                    "clientId=prop:context.propertyId",
-                    "ensureClientIdUnique=true"})
+            parameters = {"value=context.propertyValue", "label=prop:context.label",
+                    "clientId=prop:context.propertyId", "ensureClientIdUnique=true"})
     private Checkbox checkboxField;
 
     @SuppressWarnings("unused")
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "clientId=prop:context.propertyid",
-                    "validate=prop:dateFieldValidator",
-                    "ensureClientIdUnique=true"})
+            parameters = {"value=context.propertyValue", "label=prop:context.label", "clientId=prop:context.propertyid",
+                    "validate=prop:dateFieldValidator", "ensureClientIdUnique=true"})
     private DateField dateField;
 
     @SuppressWarnings("unused")
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "clientId=prop:context.propertyid",
-                    "validate=prop:calendarFieldValidator",
-                    "validationId=validationId",
-                    "ensureClientIdUnique=true"})
+            parameters = {"value=context.propertyValue", "label=prop:context.label", "clientId=prop:context.propertyid",
+                    "validate=prop:calendarFieldValidator", "ensureClientIdUnique=true"})
     private DateField calendarField;
 
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
-                    "translate=prop:passwordFieldTranslator",
-                    "validate=prop:passwordFieldValidator",
-                    "validationId=validationId",
-                    "clientId=prop:context.propertyId",
-                    "annotationProvider=context",
-                    "ensureClientIdUnique=true"})
+            parameters = {"value=context.propertyValue", "label=prop:context.label",
+                    "translate=prop:passwordFieldTranslator", "validate=prop:passwordFieldValidator",
+                    "clientId=prop:context.propertyId", "annotationProvider=context", "ensureClientIdUnique=true"})
     private PasswordField passwordField;
 
     @Component(
-            parameters = {"value=context.propertyValue",
-                    "label=prop:context.label",
+            parameters = {"value=context.propertyValue", "label=prop:context.label",
                     "translate=prop:textAreaTranslator",
-                    "validationId=validationId",
-                    "validate=prop:textAreaValidator",
-                    "clientId=prop:context.propertyId",
-                    "annotationProvider=context",
-                    "ensureClientIdUnique=true"})
+                    "validate=prop:textAreaValidator", "clientId=prop:context.propertyId",
+                    "annotationProvider=context", "ensureClientIdUnique=true"})
     private TextArea textArea;
 
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/93d06899/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContext.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContext.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContext.java
index 707101d..43fc917 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContext.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContext.java
@@ -13,7 +13,7 @@ package org.apache.tapestry5.internal;
 
 /**
  * Defines a context for validating beans.
- *
+ * 
  * @since 5.2.0
  */
 public interface BeanValidationContext
@@ -22,29 +22,21 @@ public interface BeanValidationContext
      * Returns the type of the object to validate. This method is needed for client side
validation.
      */
     Class getBeanType();
-
+    
     /**
      * Return the object to validate.
      */
     Object getBeanInstance();
-
+    
     /**
      * Returns name of the property to validate. The current name is overwritten by every
form field.
      */
     String getCurrentProperty();
-
+    
     /**
      * Sets name of the property to validate.
-     *
-     * @param propertyName
-     *         name of the property
+     * 
+     * @param propertyName name of the property
      */
     void setCurrentProperty(String propertyName);
-
-    /**
-     * Returns a validation id that should be used as a prefix for any fields inside a {@link
org.apache.tapestry5.corelib.components.BeanEditor}.
-     *
-     * @since 5.4
-     */
-    String getEditorValidationId();
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/93d06899/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContextImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContextImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContextImpl.java
index 2f3d83c..31fa1b3 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContextImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/BeanValidationContextImpl.java
@@ -14,21 +14,17 @@ package org.apache.tapestry5.internal;
 
 public class BeanValidationContextImpl implements BeanValidationContext
 {
-    private final Object bean;
-
-    private final String editorValidationId;
-
+    private Object bean;
     private String currentProperty;
 
-    public BeanValidationContextImpl(Object bean, String editorValidationId)
+    public BeanValidationContextImpl(Object bean)
     {
         this.bean = bean;
-        this.editorValidationId = editorValidationId;
     }
 
     public Class getBeanType()
     {
-        return bean == null ? null : bean.getClass();
+        return bean==null?null:bean.getClass();
     }
 
     public Object getBeanInstance()
@@ -36,18 +32,14 @@ public class BeanValidationContextImpl implements BeanValidationContext
         return bean;
     }
 
-    public String getCurrentProperty()
+    public String getCurrentProperty() 
     {
         return currentProperty;
     }
 
-    public void setCurrentProperty(String propertyName)
+    public void setCurrentProperty(String propertyName) 
     {
         this.currentProperty = propertyName;
     }
 
-    public String getEditorValidationId()
-    {
-        return editorValidationId;
-    }
 }


Mime
View raw message