Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Listening on Apache Tapestry form events

I'm a Back-end dev, and recently inherited a couple of legacy Apache Tapestry systems. My skills with Tapestry are null my knowledge on javascript medium.

I want to disable a submit button right before the submit is made to avoid multiple submits. A very simple

$(document).ready(function () {
    $("#form").submit(function () {
        $("#submitbutton").attr("disabled", true);
        return true;
    });
});

approach wont do because the submit event is propagated before Tapestry does the client-side validation, so I could be disabling the button on a submint attempt that will fail validation.

On this question I learned that Tapestry also propagetes its own events, and if I could listen on tapestry:formprocesssubmit That would probably solve my problem.

I have my CreateContract.tml file with the form, fields and buttons that already work, I have my CreateContract.java file with

@Import(library = {
            "context:js/jquery.mask.min.js",
            "context:js/maintain-contracts.js",
            "context:js/zone-overlay.js"},
            stylesheet = "context:layout/zone-overlay.css")

And my maintain-contracts.js file with

$(document).ready(function () {
    $("#form").on('tapestry:formprepareforsubmit', function () {
        console.log("I want to arrive here!");
    });
});

But it doesn't work. On this mailing list thread I see people discussing very similar matters, but they go about listening on events on a different fashion, that I don't quite grasp.

Should I create the listener inside the initializer?

I'm reffering to the event as 'tapestry:formprepareforsubmit' instead of Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT because on both my maintain-contracts.js and my console the Tapestry variable is empty - why is that?

What about the .on versus .bind versus .observe trichotomy?

the first links's question was solved using ProptypeJS Class.create, but I think i dont have access to that.

I'm I going about that wrong?

Thank you, any help is appreciated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Not an analysis of why your approach doesn't work, but a useful referral nonetheless:

Geoff Callender, creator of Tapestry JumpStart, has an excellent description of how duplicate form submissions can be avoided using a mixin.

See http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/creatingmixins1

about 4 years ago · Juan Pablo Isaza Report

0

After reading Tapestry's source code, i found out that the event is not called tapestry:formprepareforsubmit, but t5:form:prepare-for-submit, even though I found no documentation of that anywhere.

So

$(document).ready(function () {
    $("#form").on('t5:form:prepare-for-submit', function () {
        console.log("I want to arrive here!");
    });
});

Works perfectly.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!