Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda