[jira] [Resolved] (WICKET-6055) AjaxLazyLoadPanel should provide non-blocking lazy load

2017-11-19 Thread Sven Meier (JIRA)

 [ 
https://issues.apache.org/jira/browse/WICKET-6055?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sven Meier resolved WICKET-6055.

   Resolution: Fixed
Fix Version/s: 8.0.0

Thanks to all participants :)

> AjaxLazyLoadPanel should provide non-blocking lazy load
> ---
>
> Key: WICKET-6055
> URL: https://issues.apache.org/jira/browse/WICKET-6055
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-extensions
>Affects Versions: 7.1.0
>Reporter: Martijn Dashorst
>Assignee: Martijn Dashorst
> Fix For: 8.0.0
>
>
> When having multiple AjaxLazyLoadPanels on your page, they all block their 
> Wicket request thread until the content is ready to load. This can be 
> problematic when you try to wait for some background job to finish and want 
> to poll for that job to be ready, and only then update the contents.
> The improvement would be to add a method that gives the developer the option 
> to not update just yet (isReadyForReplacement) and when it returns true, 
> start the replacement. By default this would return true, implementing the 
> current behavior of the AjaxLazyLoadPanel.
> Furthermore to improve the responsiveness of the ALLP it should add a single 
> timer to the page that can be used by multiple ALLPs to update themselves. 
> The timer would poll each second and the ALLPs would use Wicket's event bus 
> to update themselves. With some reference counting, the timer can remove 
> itself from the page when all ALLPs have updated themselves.
> This enables refreshing the page as well when outside an AJAX context, or 
> having a user be impatient and pressing F5.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[wicket] Git Push Summary

2017-11-19 Thread svenmeier
Repository: wicket
Updated Branches:
  refs/heads/WICKET-6055-non-blocking-lazy [deleted] bc5662d19


wicket git commit: WICKET-6055 non-blocking lazy loading

2017-11-19 Thread svenmeier
Repository: wicket
Updated Branches:
  refs/heads/master b230793ba -> 11877422b


WICKET-6055 non-blocking lazy loading

this closes #151 and closes #240


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/11877422
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/11877422
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/11877422

Branch: refs/heads/master
Commit: 11877422bc2f5a934d8bc9c3080ffc108e4d4314
Parents: b230793
Author: Sven Meier 
Authored: Fri Oct 20 14:25:15 2017 +0200
Committer: Sven Meier 
Committed: Sun Nov 19 19:01:11 2017 +0100

--
 .../wicket/ajax/AbstractAjaxTimerBehavior.java  |  18 +-
 .../examples/ajax/builtin/LazyLoadingPage.html  |  21 +-
 .../examples/ajax/builtin/LazyLoadingPage.java  | 137 +++--
 .../ajax/markup/html/AjaxLazyLoadPanel.java | 305 +--
 .../markup/html/AjaxLazyLoadPanelTester.java|  93 +++---
 .../html/AjaxLazyLoadPanelTesterTest.java   |   4 +-
 .../org/apache/wicket/util/value/LongValue.java |  21 ++
 7 files changed, 437 insertions(+), 162 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/wicket/blob/11877422/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
--
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
index 0c9a276..7fd3606 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
@@ -112,6 +112,10 @@ public abstract class AbstractAjaxTimerBehavior extends 
AbstractDefaultAjaxBehav
@Override
protected final void respond(final AjaxRequestTarget target)
{
+   // onTimer might remove this behavior, so keep the component
+   // so the timeout can be cleared later on
+   Component component = getComponent();
+   
if (shouldTrigger())
{
onTimer(target);
@@ -124,7 +128,7 @@ public abstract class AbstractAjaxTimerBehavior extends 
AbstractDefaultAjaxBehav
}
}
 
-   clearTimeout(target.getHeaderResponse());
+   clearTimeout(component, target.getHeaderResponse());
}
 
/**
@@ -181,9 +185,9 @@ public abstract class AbstractAjaxTimerBehavior extends 
AbstractDefaultAjaxBehav

headerResponse.render(OnLoadHeaderItem.forScript(getJsTimeoutCall(updateInterval)));
}
 
-   private void clearTimeout(IHeaderResponse headerResponse)
+   private void clearTimeout(Component component, IHeaderResponse 
headerResponse)
{
-   
headerResponse.render(OnLoadHeaderItem.forScript("Wicket.Timer.clear('" + 
getComponent().getMarkupId() + "');"));
+   
headerResponse.render(OnLoadHeaderItem.forScript("Wicket.Timer.clear('" + 
component.getMarkupId() + "');"));
}
 
/**
@@ -200,7 +204,7 @@ public abstract class AbstractAjaxTimerBehavior extends 
AbstractDefaultAjaxBehav
 
if (target != null)
{
-   clearTimeout(target.getHeaderResponse());
+   clearTimeout(getComponent(), 
target.getHeaderResponse());
}
}
}
@@ -208,13 +212,15 @@ public abstract class AbstractAjaxTimerBehavior extends 
AbstractDefaultAjaxBehav
@Override
public void onRemove(Component component)
{
-   
component.getRequestCycle().find(IPartialPageRequestHandler.class).ifPresent(target
 -> clearTimeout(target.getHeaderResponse()));
+   
component.getRequestCycle().find(IPartialPageRequestHandler.class).ifPresent(target
 -> clearTimeout(component, target.getHeaderResponse()));
}
 
@Override
protected void onUnbind()
{
-   
getComponent().getRequestCycle().find(IPartialPageRequestHandler.class).ifPresent(target
 -> clearTimeout(target.getHeaderResponse()));
+   Component component = getComponent();
+   
+   
component.getRequestCycle().find(IPartialPageRequestHandler.class).ifPresent(target
 -> clearTimeout(component, target.getHeaderResponse()));
}
 
/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/11877422/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/LazyLoadingPage.html
--
diff --git 

[jira] [Commented] (WICKET-6055) AjaxLazyLoadPanel should provide non-blocking lazy load

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258549#comment-16258549
 ] 

ASF GitHub Bot commented on WICKET-6055:


Github user asfgit closed the pull request at:

https://github.com/apache/wicket/pull/240


> AjaxLazyLoadPanel should provide non-blocking lazy load
> ---
>
> Key: WICKET-6055
> URL: https://issues.apache.org/jira/browse/WICKET-6055
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-extensions
>Affects Versions: 7.1.0
>Reporter: Martijn Dashorst
>Assignee: Martijn Dashorst
>
> When having multiple AjaxLazyLoadPanels on your page, they all block their 
> Wicket request thread until the content is ready to load. This can be 
> problematic when you try to wait for some background job to finish and want 
> to poll for that job to be ready, and only then update the contents.
> The improvement would be to add a method that gives the developer the option 
> to not update just yet (isReadyForReplacement) and when it returns true, 
> start the replacement. By default this would return true, implementing the 
> current behavior of the AjaxLazyLoadPanel.
> Furthermore to improve the responsiveness of the ALLP it should add a single 
> timer to the page that can be used by multiple ALLPs to update themselves. 
> The timer would poll each second and the ALLPs would use Wicket's event bus 
> to update themselves. With some reference counting, the timer can remove 
> itself from the page when all ALLPs have updated themselves.
> This enables refreshing the page as well when outside an AJAX context, or 
> having a user be impatient and pressing F5.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6055) AjaxLazyLoadPanel should provide non-blocking lazy load

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258548#comment-16258548
 ] 

ASF GitHub Bot commented on WICKET-6055:


Github user asfgit closed the pull request at:

https://github.com/apache/wicket/pull/151


> AjaxLazyLoadPanel should provide non-blocking lazy load
> ---
>
> Key: WICKET-6055
> URL: https://issues.apache.org/jira/browse/WICKET-6055
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-extensions
>Affects Versions: 7.1.0
>Reporter: Martijn Dashorst
>Assignee: Martijn Dashorst
>
> When having multiple AjaxLazyLoadPanels on your page, they all block their 
> Wicket request thread until the content is ready to load. This can be 
> problematic when you try to wait for some background job to finish and want 
> to poll for that job to be ready, and only then update the contents.
> The improvement would be to add a method that gives the developer the option 
> to not update just yet (isReadyForReplacement) and when it returns true, 
> start the replacement. By default this would return true, implementing the 
> current behavior of the AjaxLazyLoadPanel.
> Furthermore to improve the responsiveness of the ALLP it should add a single 
> timer to the page that can be used by multiple ALLPs to update themselves. 
> The timer would poll each second and the ALLPs would use Wicket's event bus 
> to update themselves. With some reference counting, the timer can remove 
> itself from the page when all ALLPs have updated themselves.
> This enables refreshing the page as well when outside an AJAX context, or 
> having a user be impatient and pressing F5.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6055) AjaxLazyLoadPanel should provide non-blocking lazy load

2017-11-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258547#comment-16258547
 ] 

ASF subversion and git services commented on WICKET-6055:
-

Commit 11877422bc2f5a934d8bc9c3080ffc108e4d4314 in wicket's branch 
refs/heads/master from [~svenmeier]
[ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=1187742 ]

WICKET-6055 non-blocking lazy loading

this closes #151 and closes #240


> AjaxLazyLoadPanel should provide non-blocking lazy load
> ---
>
> Key: WICKET-6055
> URL: https://issues.apache.org/jira/browse/WICKET-6055
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-extensions
>Affects Versions: 7.1.0
>Reporter: Martijn Dashorst
>Assignee: Martijn Dashorst
>
> When having multiple AjaxLazyLoadPanels on your page, they all block their 
> Wicket request thread until the content is ready to load. This can be 
> problematic when you try to wait for some background job to finish and want 
> to poll for that job to be ready, and only then update the contents.
> The improvement would be to add a method that gives the developer the option 
> to not update just yet (isReadyForReplacement) and when it returns true, 
> start the replacement. By default this would return true, implementing the 
> current behavior of the AjaxLazyLoadPanel.
> Furthermore to improve the responsiveness of the ALLP it should add a single 
> timer to the page that can be used by multiple ALLPs to update themselves. 
> The timer would poll each second and the ALLPs would use Wicket's event bus 
> to update themselves. With some reference counting, the timer can remove 
> itself from the page when all ALLPs have updated themselves.
> This enables refreshing the page as well when outside an AJAX context, or 
> having a user be impatient and pressing F5.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258450#comment-16258450
 ] 

ASF GitHub Bot commented on WICKET-6499:


Github user theigl commented on a diff in the pull request:

https://github.com/apache/wicket/pull/246#discussion_r151861621
  
--- Diff: 
wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
 ---
@@ -208,24 +206,29 @@ public void detach(Component component)
 
boolean isRequired()
{
-   List constraints = findNotNullConstraints();
+   BeanValidationContext config = 
BeanValidationConfiguration.get();
+   List notNullAnnotations = 
config.getNotNullAnnotations();
+   Map constraints = 
findNotNullConstraints(
+   notNullAnnotations);
 
if (constraints.isEmpty())
{
return false;
}
 
-   HashSet validatorGroups = new HashSet();
+   Set validatorGroups = new HashSet<>();
validatorGroups.addAll(Arrays.asList(getGroups()));
 
-   for (NotNull constraint : constraints)
+   for (Map.Entry entry : 
constraints.entrySet())
{
-   if (canApplyToDefaultGroup(constraint) && 
validatorGroups.isEmpty())
+   final Annotation annotation = entry.getKey();
+   ConstraintDescriptor constraintDescriptor = 
constraints.get(annotation);
--- End diff --

Sorry, totally overlooked that. Changed.


> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258449#comment-16258449
 ] 

ASF GitHub Bot commented on WICKET-6499:


Github user solomax commented on a diff in the pull request:

https://github.com/apache/wicket/pull/246#discussion_r151861578
  
--- Diff: 
wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
 ---
@@ -208,24 +206,29 @@ public void detach(Component component)
 
boolean isRequired()
{
-   List constraints = findNotNullConstraints();
+   BeanValidationContext config = 
BeanValidationConfiguration.get();
+   List notNullAnnotations = 
config.getNotNullAnnotations();
+   Map constraints = 
findNotNullConstraints(
+   notNullAnnotations);
 
if (constraints.isEmpty())
{
return false;
}
 
-   HashSet validatorGroups = new HashSet();
+   Set validatorGroups = new HashSet<>();
validatorGroups.addAll(Arrays.asList(getGroups()));
 
-   for (NotNull constraint : constraints)
+   for (Map.Entry entry : 
constraints.entrySet())
{
-   if (canApplyToDefaultGroup(constraint) && 
validatorGroups.isEmpty())
+   final Annotation annotation = entry.getKey();
+   ConstraintDescriptor constraintDescriptor = 
constraints.get(annotation);
--- End diff --

you can use `entry.getValue()` here


> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258447#comment-16258447
 ] 

ASF GitHub Bot commented on WICKET-6499:


Github user theigl commented on the issue:

https://github.com/apache/wicket/pull/246
  
@solomax: Thanks for the quick feedback. I adjusted the PR accordingly.


> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258439#comment-16258439
 ] 

ASF GitHub Bot commented on WICKET-6499:


Github user solomax commented on a diff in the pull request:

https://github.com/apache/wicket/pull/246#discussion_r151861199
  
--- Diff: 
wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
 ---
@@ -208,24 +206,28 @@ public void detach(Component component)
 
boolean isRequired()
{
-   List constraints = findNotNullConstraints();
+   BeanValidationContext config = 
BeanValidationConfiguration.get();
+   List notNullAnnotations = 
config.getNotNullAnnotations();
+   Map constraints = 
findNotNullConstraints(
+   notNullAnnotations);
 
if (constraints.isEmpty())
{
return false;
}
 
-   HashSet validatorGroups = new HashSet();
+   HashSet validatorGroups = new HashSet<>();
validatorGroups.addAll(Arrays.asList(getGroups()));
--- End diff --

I would use `Set` here


> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258440#comment-16258440
 ] 

ASF GitHub Bot commented on WICKET-6499:


Github user solomax commented on a diff in the pull request:

https://github.com/apache/wicket/pull/246#discussion_r151861201
  
--- Diff: 
wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
 ---
@@ -208,24 +206,28 @@ public void detach(Component component)
 
boolean isRequired()
{
-   List constraints = findNotNullConstraints();
+   BeanValidationContext config = 
BeanValidationConfiguration.get();
+   List notNullAnnotations = 
config.getNotNullAnnotations();
+   Map constraints = 
findNotNullConstraints(
+   notNullAnnotations);
 
if (constraints.isEmpty())
{
return false;
}
 
-   HashSet validatorGroups = new HashSet();
+   HashSet validatorGroups = new HashSet<>();
validatorGroups.addAll(Arrays.asList(getGroups()));
 
-   for (NotNull constraint : constraints)
+   for (Annotation constraint : constraints.keySet())
{
--- End diff --

`entrySet()` can be used here to avoid `double search`


> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258436#comment-16258436
 ] 

ASF GitHub Bot commented on WICKET-6499:


GitHub user theigl opened a pull request:

https://github.com/apache/wicket/pull/246

WICKET-6499 Support Bean Validation 2.0

This PR adds support for Bean Validation 2.0 to `wicket-bean-validation`.

It extends scanning of `@NotNull` annotations to `@NotEmpty`  and 
`@NotBlank` and supports registering further annotations that should be treated 
as not-null constraints to guard against future changes.

See https://issues.apache.org/jira/browse/WICKET-6499

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/theigl/wicket WICKET-6499-bean-validation-2x

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/wicket/pull/246.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 #246


commit a7bf98215f7e6f1331b9689f9c8ca68180a93544
Author: Thomas Heigl 
Date:   2017-11-19T10:26:57Z

WICKET-6499 Support Bean Validation 2.0




> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (WICKET-6499) Support for Bean Validation 2.0

2017-11-19 Thread Thomas Heigl (JIRA)

[ 
https://issues.apache.org/jira/browse/WICKET-6499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16258403#comment-16258403
 ] 

Thomas Heigl commented on WICKET-6499:
--

I just noticed that master is already depending on BV 2.0:

{code}

javax.validation
validation-api
2.0.0.Final
provided

{code}

> Support for Bean Validation 2.0
> ---
>
> Key: WICKET-6499
> URL: https://issues.apache.org/jira/browse/WICKET-6499
> Project: Wicket
>  Issue Type: Improvement
>  Components: wicket-bean-validation
>Reporter: Thomas Heigl
>
> Bean Validation 2.0 and the reference implementation Hibernate Validator 6.0 
> were [recently released|http://beanvalidation.org/2.0/].
> I upgraded my application and discovered that fields annotated with 
> {{@NotEmpty}} and {{@NotBlank}} are not automatically marked as required 
> anymore.
> So I started to investigate.
> h4. Bean Validation 1.x
> Wicket {{PropertyValidator}} marks form components as required if it 
> encounters the {{@NotNull}} annotation on a field:
> {code}
> boolean isRequired()
>   {
>   List constraints = findNotNullConstraints();
>   for (NotNull constraint : constraints)
>   {
>   ...
>   }
>   return false;
>   }
> {code}
> In Bean Validation 1.x, this lookup returns not only properties annotated 
> with 
> - {{@javax.validation.constraints.NotNull}}
> but also properties annotated with  
> - {{@org.hibernate.validator.constraints.NotEmpty}} 
> - {{@org.hibernate.validator.constraints.NotBlank}} 
> because these annotations are implemented as composed constraints:
> {code}
> @NotNull
> @Deprecated
> public @interface NotEmpty {}
> {code}
> {code}
> @NotNull
> @Deprecated
> public @interface NotBlank {}
> {code}
> h4. Bean Validation 2.x
> Both annotations are now deprecated and replaced with "official" versions: 
> - {{javax.validation.constraints.NotEmpty}}
> - {{javax.validation.constraints.NotBlank}}
> The new annotations are *not* implemented as composed constraints, and thus 
> do *not* contain the {{@NotNull}} annotation.
> I asked about the rationale and the recommended solution on the [HV 
> forum|https://forum.hibernate.org/viewtopic.php?f=9=1044998=0] and 
> got the following reply from the Hibernate Team:
> {quote}
> When promoting @NotEmpty and @NotBlank from HV to the Bean Validation spec we 
> decided to define them as composed constraints (as their previous 
> counterparts), but instead leave this as an implementation detail to BV 
> providers. The reason being, that the implementation can be more efficient 
> when using a single constraint validator instead of relying on constraint 
> composition.
> So you'd indeed have to expand your scan to look for @NotNull, @NotEmpty and 
> @NotBlank.
> {quote}
> I suggest that {{PropertyValidator}} should scan for these new annotations 
> when Bean Validation 2.0 is on the classpath.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)