[ 
https://issues.apache.org/jira/browse/TAP5-860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760317#action_12760317
 ] 

Howard M. Lewis Ship commented on TAP5-860:
-------------------------------------------

Here's a monkey patch I'm using for this problem:

Tapestry.FieldEventManager.prototype.validateInput = function() {

        if (this.field.disabled)
                return false;

        if (!this.field.isDeepVisible())
                return false;

        var t = $T(this.field);

        var value = $F(this.field);

        t.validationError = false;

        if (this.requiredCheck)
                this.requiredCheck.call(this, value);

        // Don't try to validate blank values; if the field is required, that
        // error is already
        // noted and presented to the user.

        if (this.field.type == "checkbox") {
                this.field.fire(Tapestry.FIELD_VALIDATE_EVENT, {
                        value : this.field.checked,
                        translated : this.field.checked
                });
        } else {
                if (!t.validationError && !value.blank()) {
                        var translated = this.translator(value);

                        // If Format went ok, perhaps do the other validations.

                        if (!t.validationError) {
                                this.field.fire(Tapestry.FIELD_VALIDATE_EVENT, {
                                        value : value,
                                        translated : translated
                                });
                        }
                }
        }

        // Lastly, if no validation errors were found, remove the decorations.

        if (!t.validationError)
                this.field.removeDecorations();

        return t.validationError;
};

> JavaScript errors when adding validations to checkboxes
> -------------------------------------------------------
>
>                 Key: TAP5-860
>                 URL: https://issues.apache.org/jira/browse/TAP5-860
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.2.0.0, 5.0.18
>            Reporter: Howard M. Lewis Ship
>
> Tapestry doesn't support validations on checkboxes out of the box (after all, 
> it's either on or off).  Perhaps supporting the required validator would not 
> be so bad.
> However, it is reasonable to add a validator on the client side, for example, 
> to implement "if this is selected, this must be checked as well" scenarios.
> Anyway, because $F() of a checkbox return nulls, this line fails
>         if (!t.validationError && ! value.blank())
> because value is null
> This is in Tapestry.FieldEventManager.validateInput

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

Reply via email to