GitHub user paulspeijers opened a pull request:
https://github.com/apache/wicket/pull/216
PropertyValidator does not work with dynamic validation groups
The Wicket property validator does not work with dynamic validation groups
because of the following issues:
1. It can not cope with the case in which the Default validation group is
provided explicitly
1. The initial validation groups determine whether required should be set
on the component. But the PropertyValidator never unsets the flag.
When using a Wicket property validator you can provide a model for the
validation groups:
```
IModel<Class<?>[]> validationGroups = Model.of(new Class[]{Default.class});
new PropertyValidator<>(validationGroups);
```
Let's say I have the following model object:
```
public class MyObject {
@NotNull
private String name;
@NotNull(groups=AdditionalValidations.class)
private String additional;
}
```
Then the @NotNull constraint on the name attribute is NOT performed when
submitting the form.
This is caused by the fact that no validations are performed within
FormComponent.validateValidators. On the following line both conditions
evaluate to false:
`if (isNull == false || validator instanceof INullAcceptingValidator<?>)`
The trick to perform "required" validations is that the PropertyValidator
sets the component to required within its onConfigure method:
`this.component.setRequired(true);`
However, this is only performed when isRequired() evaluates to true, which
is NOT the case in my example. This is related to issue 1:
When the Default validation group is provided explicitly, isRequired
returns the wrong result.
Issue 2 has to do with the required flag only being set once by the
PropertyValidator:
Given the example model object above. Assume that when I create the form
components I don't set them required explicitly
(formComponent.setRequired(true), but I rather let it up to the
PropertyValidator because I want to describe my validations on one place, the
model object. So, when I initially create the PropertyValidator the
"additional" model object attribute is NOT set to required within
PropertyValidator.onConfigure, because the validation groups don't match. Then
when I would dynamically change the validation groups:
`validationGroups.setObject(new Class[]{Default.class,
AdditionalValidations.class});`
Then subsequently a required/NotNull validation should be performed for the
"additional" attribute when submitting the form. However, it is not performed
because within PropertyValidator.onConfigure it is only set to required once,
and not updated at a later stage.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/wicket master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/wicket/pull/216.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #216
----
commit b207a2b044e074c57a47b83e908ecbb76574bc8b
Author: Sven Meier <[email protected]>
Date: 2016-07-22T14:26:32Z
WICKET-5866 protected #createConverter()
commit ff3de1937d50ea28c8816715e4cd0e703440eff5
Author: Sven Meier <[email protected]>
Date: 2016-07-24T18:46:19Z
WICKET-6215 use getModel().setObject(null) Ãnstead
commit e79fcb8787187108e8a16b2ae9ababecfcc76cf2
Author: Sven Meier <[email protected]>
Date: 2016-07-24T18:50:48Z
WICKET-6108 revert Event.fix(): passed event should always be fixed
commit 29c5221c151e71e83e0c49cc653d3ed3dfe59d41
Author: Andrea Del Bene <[email protected]>
Date: 2016-07-27T09:23:22Z
WICKET-6216 Problem with queued components and border
commit 29d832f03220837fd14715c6a7e0c7350667fe1f
Author: Andrea Del Bene <[email protected]>
Date: 2016-07-27T13:50:16Z
WICKET-6217 Enclosure broken within Border/Panel
commit 936b0336d74b101f84e03afb3c1a21001a52f842
Author: Andrea Del Bene <[email protected]>
Date: 2016-07-27T14:21:18Z
WICKET-6217 Added test case and improved code
commit 397840df5ec94358f3205e7a38f5917a60a459c8
Author: Tobias Soloschenko <[email protected]>
Date: 2016-08-01T16:27:24Z
WICKET-6194 - Create a server specific http/2 push support
commit 2273b397b5f348668fda3d7d8fb9f3806290a11d
Author: Andrea Del Bene <[email protected]>
Date: 2016-08-03T13:11:58Z
WICKET-6221 WicketTester - missing border path
commit 86256b0ad8137f2afe4f124e92779aaa0f6c46e3
Author: Sven Meier <[email protected]>
Date: 2016-07-30T08:46:51Z
WICKET-6220 value of void element should be null
commit e173e8c07a4bf2437a35bdb05fdfa1762ba8f590
Author: Sven Meier <[email protected]>
Date: 2016-08-01T08:49:21Z
WICKET-6220 improved support for void elements; unified code for
createTagsXX and createTagXX
commit 2b8ba3a6ef2dff3bb66ef1930f2b5773c23e069e
Author: Sven Meier <[email protected]>
Date: 2016-08-11T09:15:00Z
WICKET-6210 support zero file size for upload
commit 061c0e9038c8f72d19b89efbb9188912f0289e6c
Author: Andrea Del Bene <[email protected]>
Date: 2016-08-11T12:55:44Z
Added some documentation for IModel lambda support
commit 76116aa467590378ae6b5d5acc8a153246fc9ee4
Author: Tobias Soloschenko <[email protected]>
Date: 2016-08-11T18:43:52Z
WICKET-6194 PushHeaderItem handles client side cache
commit bf1e70aec1567b80af216e0d0dfea55ac2f9d112
Author: Andrea Del Bene <[email protected]>
Date: 2016-08-11T19:24:39Z
WICKET-6190 fixed indentation problem with lambda examples and a problem
with pdf generation.
commit 2b28c7fcc0d7f6809a4fb93927338e0da4a47276
Author: Tobias Soloschenko <[email protected]>
Date: 2016-08-12T19:36:48Z
WICKET-6194 Fixed exception message / guide information
commit 0b0158b475148d1b18f8c73b64dc07bf5463fb34
Author: Andrea Del Bene <[email protected]>
Date: 2016-08-13T19:03:37Z
WICKET-6190 Completed the section about default methods for IModel.
commit cf910b0317b60e55b5b9946c857d88102ee600b4
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-15T12:59:39Z
WICKET-6192 Remove recreateBookmarkablePagesAfterExpiry check in
AbstractBookmarkableMapper#mapHandler
commit f5cf5e8558861fa8fbcdcc25e37d71d76bacc209
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-15T13:26:14Z
WICKET-6225 Button wrongly sets its model object as 'value' attribute
commit b8d6c23c662912a358b4da2da9828ddbbbe1cba2
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-15T14:29:06Z
WICKET-6225 Button wrongly sets its model object as 'value' attribute
If there is no model object then use the text from the markup
commit bec52515f1bb2570f09140ba6f457c369f3a56b1
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-16T12:11:36Z
WICKET-6227 CharSequenceResource calculates wrong length when there are
unicode symbols
commit 94cea576b67f1e55e2accc1caa22eddf04225b40
Author: Tobias Soloschenko <[email protected]>
Date: 2016-08-18T19:49:36Z
WICKET-6194 concurrency fix / cache handling / doc
commit 1910494a31840acc79b631ef12a37748a005ab7a
Author: Sven Meier <[email protected]>
Date: 2016-08-18T20:04:02Z
updated javadoc for IInitializer
commit 130cfb6400b04fdbaba028d49581b28e77c7423b
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-19T06:27:21Z
Fix typo in javadoc
commit ece7575f5ea74ec27f88618fd287e4348aa9cc35
Author: Andrea Del Bene <[email protected]>
Date: 2016-08-19T13:53:50Z
WICKET-6041 Nested forms / parent FormComponents do not reflect updated
model when nested form submitted
commit 431fba86e1215bc2e504fd58de9c045281cc60e0
Author: Sven Meier <[email protected]>
Date: 2016-08-19T17:10:36Z
WICKET-5623 renamed inner classes, added javadoc
commit ba393ffa2bf6480d4981e4b48c7aa6a19bd5b9c6
Author: Andrea Del Bene <[email protected]>
Date: 2016-08-20T10:25:35Z
WICKET-6041 InputChange called on the outer form to keep raw values
commit ba8cfd3af0113210a7818c11d6858d72f0d5a1cf
Author: Sven Meier <[email protected]>
Date: 2016-08-22T16:33:51Z
WICKET-6004 removed final #renderHead(Component, IHeaderRepsonse) left-over
from Wicket 1.4
commit e17db7f8d7caa08f72153962104da8fb95bac1f9
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-23T19:30:46Z
WICKET-6229 Introduce a new setting in ExceptionSettings to control whether
to throw exception or log a WARN when requesting for markup id on
non-renderable component
commit 8c0c0b8004467906ab7d6c09ff72523da7755879
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-23T19:49:54Z
WICKET-6228 Hide AuthenticatedWebSession#signOut() from the public API
Make AuthenticatedWebSession#signOut() an alias to #invalidate()
commit 1dff8aa94c91731e1f3b86d46a80c0d484d5d8d4
Author: Martin Tzvetanov Grigorov <[email protected]>
Date: 2016-08-24T21:54:59Z
WICKET-6230 Infinite redirection when using UrlPathPageParametersEncoder
Treat specially only "." and "..". Any longer sequence of dots should be
left as is.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---