You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2013/10/28 09:16:24 UTC
[08/47] git commit: WICKET-5329 "Required" flag initialized too early
in PropertyValidator
WICKET-5329 "Required" flag initialized too early in PropertyValidator
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/cec6e031
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/cec6e031
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/cec6e031
Branch: refs/heads/wicket-4997
Commit: cec6e0311d2773fde1165bf4404d2336e94785db
Parents: 2890198
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Sep 2 12:59:29 2013 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Sep 2 12:59:57 2013 +0300
----------------------------------------------------------------------
.../bean/validation/PropertyValidator.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/cec6e031/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
index 04a82bc..032a818 100644
--- a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
+++ b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
@@ -61,6 +61,12 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
private Property property_;
private final IModel<Class<?>[]> groups_;
+ /**
+ * A flag that indicates whether {@linkplain #setComponentRequiredFlag()}
+ * has been called for this behavior.
+ */
+ private boolean requiredFlagSet;
+
public PropertyValidator(Class<?>... groups)
{
this(null, groups);
@@ -130,10 +136,20 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
// @Size on String vs Collection - done but need to add a key for each superclass/interface
this.component = (FormComponent<T>)component;
-
- setComponentRequiredFlag();
}
+ @Override
+ public void onConfigure(Component component)
+ {
+ super.onConfigure(component);
+ if (requiredFlagSet == false)
+ {
+ // "Required" flag is calculated upon component's model property, so we must ensure,
+ // that model object is accessible (i.e. component is already added in a page).
+ requiredFlagSet = true;
+ setComponentRequiredFlag();
+ }
+ }
@Override
public void detach(Component component)