You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sven Ackermann (JIRA)" <ji...@apache.org> on 2017/10/13 10:48:00 UTC

[jira] [Updated] (WICKET-6482) CompoundValidator should implement all Behavior methods

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

Sven Ackermann updated WICKET-6482:
-----------------------------------
    Description: 
Hi,
I recently had an issue with a {{CompoundValidator}} using a {{StringValidator}} inside.
The problem was that the {{TextField}} which had the validator assigned did not have a "maxlength" attribute in its HTML representation. Normally {{StringValidator}} outputs this attribute automatically when the maximum is not null and the HTML field is of type "input". This is handled in {{StringValidator.onComponentTag}}.
Unfortunately, {{CompoundValidator}} does not delegate its own {{onComponentTag}} method to the contained validators, so the {{onComponentTag}} method of the included {{StringValidator}} is never called.

I think, all {{Behavior}} methods should be implemented by {{CompoundValidator}} to delegate to the contained validators because this is the expected behavior.
For {{onComponentTag}} it could look like this:

{code:java}
@Override
public void onComponentTag(Component component, ComponentTag tag) {
  for (IValidator<T> validator : validators) {
    if (validator instanceof Behavior) {
      Behavior behavior = (Behavior) validator;
      behavior.onComponentTag(component, tag);
    }
  }
}
{code}


  was:
Hi,
I recently had an issue with a {{CompoundValidator}} using a {{StringValidator}} inside.
The problem was that the {{TextField}} which had the validator assigned did not have a "maxlength" attribute in its HTML representation. Normally {{StringValidator}} outputs this attribute automatically when the maximum is not null and the HTML field is of type "input". This is handled in {{StringValidator.onComponentTag}}.
Unfortunately, {{CompoundValidator}} does not delegate its own {{onComponentTag}} method to the contained validators, so the {{onComponentTag}} method of the included {{StringValidator}} is never called.

I think, all {{Behavior}} methods should be implemented by {{CompoundValidator}} to delegate to the contained validators because this is the expected behavior.


> CompoundValidator should implement all Behavior methods
> -------------------------------------------------------
>
>                 Key: WICKET-6482
>                 URL: https://issues.apache.org/jira/browse/WICKET-6482
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 7.8.0
>            Reporter: Sven Ackermann
>
> Hi,
> I recently had an issue with a {{CompoundValidator}} using a {{StringValidator}} inside.
> The problem was that the {{TextField}} which had the validator assigned did not have a "maxlength" attribute in its HTML representation. Normally {{StringValidator}} outputs this attribute automatically when the maximum is not null and the HTML field is of type "input". This is handled in {{StringValidator.onComponentTag}}.
> Unfortunately, {{CompoundValidator}} does not delegate its own {{onComponentTag}} method to the contained validators, so the {{onComponentTag}} method of the included {{StringValidator}} is never called.
> I think, all {{Behavior}} methods should be implemented by {{CompoundValidator}} to delegate to the contained validators because this is the expected behavior.
> For {{onComponentTag}} it could look like this:
> {code:java}
> @Override
> public void onComponentTag(Component component, ComponentTag tag) {
>   for (IValidator<T> validator : validators) {
>     if (validator instanceof Behavior) {
>       Behavior behavior = (Behavior) validator;
>       behavior.onComponentTag(component, tag);
>     }
>   }
> }
> {code}



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