/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
new AjaxButton("save") { @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new DisableComponentCallDecorator(super.getAjaxCallDecorator(), this); } } class DisableComponentCallDecorator extends AjaxPreprocessingCallDecorator { super(delegate); this.selector = jquerySelector; } super(delegate); component.setOutputMarkupId(true); this.selector = "#" + component.getMarkupId(); } @Override public CharSequence preDecorateScript(CharSequence script) { return "$('" + selector + "').addClass('disabled_while_waiting').attr('disabled','disabled'); " + super.preDecorateScript(script); } @Override public CharSequence preDecorateOnSuccessScript(CharSequence script) { return "$('" + selector + "').removeAttr('disabled'); " + super.preDecorateOnSuccessScript(script); } @Override public CharSequence preDecorateOnFailureScript(CharSequence script) { return "$('" + selector + "').removeAttr('disabled'); " + super.preDecorateOnFailureScript(script); } }