Sure ...I think you can generally do something like:

-) Use
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form/validation.js?view=markupas
a reference.

-) Override tapestry.form.validation.validateForm(form, props) with
something else ....Like maybe

tapestry.form.validation.validateForm=function(form,props) {
       var passed = tapestry.form.validation.prototype.apply(this,
arguments);

       // prevent submission
       return false;
}

Something like that anyways.

On 5/4/07, Geoff Callender <[EMAIL PROTECTED]> wrote:

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





--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Reply via email to