You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Johan Compagner (JIRA)" <ji...@apache.org> on 2007/11/17 16:37:43 UTC

[jira] Closed: (WICKET-1153) Validation with AbstractFormValidator doesn't work if there are DateTimeFields

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

Johan Compagner closed WICKET-1153.
-----------------------------------

    Resolution: Invalid

> Validation with AbstractFormValidator doesn't work if there are DateTimeFields
> ------------------------------------------------------------------------------
>
>                 Key: WICKET-1153
>                 URL: https://issues.apache.org/jira/browse/WICKET-1153
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-datetime
>    Affects Versions: 1.3.0-beta4
>            Reporter: Roberto Fasciolo
>            Assignee: Johan Compagner
>             Fix For: 1.3.0-rc2
>
>
> If in dependentFormComponents of a class extending AbstractFormValidator there are some DateTimeFields the validator code is never called. Example:
> public final class DateRangeValidator extends AbstractFormValidator {
>     private final transient Logger logger = Logger.getLogger(this.getClass().getName());
>     private final DateTimeField dateFrom;
>     private final DateTimeField dateTo;
>     public DateRangeValidator(final DateTimeField dateFrom, final DateTimeField dateTo) {
>         if (dateFrom == null) {
>             throw new NullPointerException("From date field cannot be null");
>         }
>         if (dateTo == null) {
>             throw new NullPointerException("From date field cannot be null");
>         }
>         this.dateFrom = dateFrom;
>         this.dateTo = dateTo;
>         if (this.logger.isDebugEnabled()) {
>             this.logger.debug("Validator constructed");
>         }
>     }
>     @Override
>     public FormComponent[] getDependentFormComponents() {
>         // TODO this should return an array with the 2 objects, but if returning that the
>         // validator doesn't work at all.
>         // return new FormComponent[] { dateFrom, dateTo };
>         return null;
>     }
>     @Override
>     public void validate(final Form form) {
>         Date from = (Date) this.dateFrom.getConvertedInput();
>         Date to = (Date) this.dateTo.getConvertedInput();
>         if (this.logger.isDebugEnabled()) {
>             this.logger.debug("Date from: '" + from + "'");
>             this.logger.debug("Date to: '" + to + "'");
>         }
>         if (from == null || to == null) {
>             return;
>         }
>         if (to.compareTo(from) <= 0) {
>             error(this.dateTo);
>         }
>     }
> }
> If that class returns the FormComponent[] with the 2 DateTimeFields validate is never called, if that method returns null validate is called.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.