I've got this working in 4.0 but need some help getting it working with 4.1. It involves Tapestry's javascript.

I have some "do it once" components, eg. SubmitOnce and DirectLinkOnce; which address the problem of multiple clicks (causing duplicate submissions). I've adapted them from the tapestry-bayeaux project and upgraded them to Tap 4.0.

In javascript they check if a variable called "ongoingSubmit" is true. If not, they set it to true and do what Submit or DirectLink would normally do. Otherwise they do nothing, ie. they ignore multiple clicks. That much works just fine in both 4.0 and 4.1.

The tricky bit is when client validation detects an error and therefore ongoingSubmit should be set to false. In 4.0 I handle this by overriding Tapestry javascript in my own script:

Tapestry.default_invalid_field_handler = function(event, field, message)
        {
          if (!event.abort && !field.disabled)
          {
            Tapestry.set_focus(field);
            window.alert(message);
        
            event.abort = true;
            event.cancel_handlers = true;
        
            ongoingSubmit = false;
          }
        }

The only difference is one added line

            ongoingSubmit = false;

Q: In Tap 4.1, what should I do? And is there a more elegant way than copying and pasting the entire function as I've done?

Geoff


Reply via email to