> Unfortunately it seems that it does not help against these error-
> bubbles.

To override the client side you'll need to read tapestry.js and follow some of 
what it does. Personally I feel that the error bubbles should not be part of 
the T5 core, but an optional example validation module.

I created an inline validation decorator which puts the validation messages 
inside the field labels (for accessibility reasons) and overrode parts of 
tapestry.js in a js file added in our page layout so it comes on every page. 
Removing and changing the client side validation functions. Compare with the 
std tapestry.js versions and hopefully it will help you.

The js looks like this:

Tapestry.FormEventManager.addMethods(
{
        initialize : function(form)
        {
                this.form = $(form);

                this.form.onsubmit = 
this.handleSubmit.bindAsEventListener(this);
        },

        handleSubmit : function(domevent)
        {
                var t = $T(this.form);

                t.validationError = false;

                this.form.fire(Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT, 
this.form);

                // This flag can be set to prevent the form from submitting 
normally.
                // This is used for some Ajax cases where the form submission 
must
                // run via Ajax.Request.

                if (this.preventSubmission)
                {
                        // Prevent the normal submission.

                        Event.stop(domevent);

                        // Instead ...

                        this.form.fire(Tapestry.FORM_PROCESS_SUBMIT_EVENT);

                        return false;
                }

                // Validation is OK, not doing Ajax, continue as planned.

                return true;
        }
});

Tapestry.FieldEventManager.addMethods(
{
        initialize : function(field)
        {
                this.field = $(field);

                var id = this.field.id;
                this.label = $(id + '-label');
                this.icon = $(id + '-icon');

                this.translator = Prototype.K;

                document.observe(Tapestry.FOCUS_CHANGE_EVENT, function(event)
                {
                        // If changing focus *within the same form* then 
perform validation.
                        // Note that Tapestry.currentFocusField does not change
                        // until after the FOCUS_CHANGE_EVENT notification.
                        if (Tapestry.currentFocusField == this.field && 
this.field.form == event.memo.form) {
                                this.validateInput();
                        }
                }.bindAsEventListener(this));
        },

        // Removes validation decorations if present.
        removeDecorations : function()
        {
                this.field.removeClassName("t-error");

                if (this.label) {
                        this.icon.hide();
                        this.label.insert(this.icon);
                        var errorMsgId = this.field.id + ':error';
                        if (!this.errorMessage) {
                                this.errorMessage = $(errorMsgId);
                        }
                        if (this.errorMessage) {
                                Element.remove(this.errorMessage);
                                this.errorMessage = null;
                        }
                }
        },

        /**
         * Show a validation error message, which will add decorations to the
         * field and it label.
         * @param message validation message to display
         */
        showValidationMessage : function(message)
        {
                $T(this.field).validationError = true;
                $T(this.field.form).validationError = true;
                this.field.addClassName("t-error");

                if (this.label) {
                        var errorMsgId = this.field.id + ':error';
                        if (!this.errorMessage) {
                                this.errorMessage = $(errorMsgId);
                        }
                        if (!this.errorMessage) {
                                this.errorMessage = new Element('span', {'id': 
errorMsgId, 'class': 't-error'});
                                this.label.insert({ bottom: this.errorMessage});
                        }
                        this.errorMessage.update(message);
                        this.errorMessage.insert({top: this.icon});
                        this.icon.show();
                }
        }
});


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to