You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2021/07/15 11:22:37 UTC

[wicket] branch master updated: WICKET-6901 document size modifier

This is an automated email from the ASF dual-hosted git repository.

svenmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ec7b18  WICKET-6901 document size modifier
2ec7b18 is described below

commit 2ec7b18def4568281289a268636761a4f5ff57ce
Author: Sven Meier <sv...@apache.org>
AuthorDate: Thu Jul 15 13:20:31 2021 +0200

    WICKET-6901 document size modifier
---
 .../wicket/bean/validation/BeanValidationConfiguration.java | 13 ++++++++++++-
 .../org/apache/wicket/bean/validation/ITagModifier.java     |  5 ++++-
 .../apache/wicket/bean/validation/PropertyValidator.java    |  7 ++++---
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/BeanValidationConfiguration.java b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/BeanValidationConfiguration.java
index 5399c83..747643c 100644
--- a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/BeanValidationConfiguration.java
+++ b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/BeanValidationConfiguration.java
@@ -69,7 +69,13 @@ public class BeanValidationConfiguration implements BeanValidationContext
 	}
 
 	/**
-	 * Registeres a tag modifier for a specific constraint annotation
+	 * Registers a tag modifier for a specific constraint annotation.
+	 * <p>
+	 * By default {@link Size} constraints are automatically mapped to <code>maxlength</code> of text inputs,
+	 * this can be disabled by registering a {@link ITagModifier#NoOp} instead:
+	 * <code>
+	 * configuration.register(Size.class, ITagModifier.NoOp});
+	 * </code>
 	 * 
 	 * @param annotationType
 	 *            constraint annotation such as {@link Size}
@@ -88,6 +94,11 @@ public class BeanValidationConfiguration implements BeanValidationContext
 		return this;
 	}
 
+	/**
+	 * Get the registered modifier for the given annotation.
+	 * 
+	 * @see #register(Class, ITagModifier)
+	 */
 	@Override
 	@SuppressWarnings("unchecked")
 	public <T extends Annotation> ITagModifier<T> getTagModifier(Class<T> annotationType)
diff --git a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/ITagModifier.java b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/ITagModifier.java
index 2daef97..958d9d6 100644
--- a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/ITagModifier.java
+++ b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/ITagModifier.java
@@ -29,4 +29,7 @@ public interface ITagModifier<T extends Annotation>
 	 *            constraint annotation
 	 */
 	void modify(FormComponent<?> component, ComponentTag tag, T annotation);
-}
+	
+	public static final ITagModifier<?> NoOp = (component, tag, annotation) -> {
+	};
+}
\ No newline at end of file
diff --git a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
index be35f36..ba40075 100644
--- a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
+++ b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
@@ -32,14 +32,15 @@ import org.apache.wicket.validation.IValidatable;
  * 
  * <p>
  * The validator will set the required flag on the form component it is attached to based on the
- * presence of the @NotNull annotation. Notice, the required flag will only be set to {@code true},
+ * presence of the @NotNull annotation, see {@link BeanValidationContext#isRequiredConstraint(ConstraintDescriptor)}
+ * for details. Notice, the required flag will only be set to {@code true},
  * components with the required flag already set to {@code true} will not have the flag set to
  * {@code false} by this validator.
  * </p>
  * 
  * <p>
- * The validator will allow {@link ITagModifier}s configured in {@link BeanValidationConfiguration}
- * to mutate the markup tag of the component it is attached to.
+ * The validator will allow {@link ITagModifier}s registered on {@link BeanValidationContext}
+ * to mutate the markup tag of the component it is attached to, e.g. add a <code>maxlength</code> attribute.
  * </p>
  * 
  * <p>