You can accomplish this with a mixin
ClickOnce.java
@Import(library="context:js/clickonce.js")
public class ClickOnce {
@Inject
private JavaScriptSupport javaScriptSupport;
@InjectContainer
private ClientElement clientElement;
@AfterRender
public void afterRender() {
// Tell the Tapestry.Initializer to do the initializing of a
ClickOnce, which it will do when the DOM has been
// fully loaded.
JSONObject spec = new JSONObject();
spec.put("elementId", clientElement.getClientId());
javaScriptSupport.addInitializerCall("clickonce", spec);
}
}
clickonce.js
// A class that ignores clicks after the first one.
var ClickOnce = function(elementId) {
this.elementId = elementId;
alreadyClickedOnce = false;
}
$.extend(ClickOnce.prototype, {
bind : function() {
var id = "#"+this.elementId;
$(id).on('click', this, function(event) {
//prevent default events
if (alreadyClickedOnce) {
event.preventDefault();
}
alreadyClickedOnce = true;
});
}
});
// Extend the Tapestry.Initializer with a static method that instantiates a
ClickOnce.
Tapestry.Initializer.clickonce = function(spec) {
new ClickOnce(spec.elementId).bind();
}
example Usage in .tml
<t:submit t:id="saveImageSubmit" value="Save image" t:mixins="clickonce"/>
On Sat, Mar 15, 2014 at 11:03 AM, John <[email protected]> wrote:
> The user presses submit the server takes a while during which submit can
> be pressed again.
>
> I need to rerender the form inputs disabled and then fire the submit. How
> to?
>
> John
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>