Posted By

ronaldtm on 01/30/09


Tagged

ajax javascript wicket


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Before-submit scripts for Wicket's AjaxButton


 / Published in: Java
 

  1. new AjaxButton("save") {
  2. @Override
  3. protected IAjaxCallDecorator getAjaxCallDecorator() {
  4. return new DisableComponentCallDecorator(super.getAjaxCallDecorator(), this);
  5. }
  6. }
  7.  
  8. class DisableComponentCallDecorator extends AjaxPreprocessingCallDecorator {
  9. private final String selector;
  10. private DisableComponentCallDecorator(IAjaxCallDecorator delegate, String jquerySelector) {
  11. super(delegate);
  12. this.selector = jquerySelector;
  13. }
  14. private DisableComponentCallDecorator(IAjaxCallDecorator delegate, Component component) {
  15. super(delegate);
  16. component.setOutputMarkupId(true);
  17. this.selector = "#" + component.getMarkupId();
  18. }
  19. @Override
  20. public CharSequence preDecorateScript(CharSequence script) {
  21. return "$('" + selector + "').addClass('disabled_while_waiting').attr('disabled','disabled'); " + super.preDecorateScript(script);
  22. }
  23. @Override
  24. public CharSequence preDecorateOnSuccessScript(CharSequence script) {
  25. return "$('" + selector + "').removeAttr('disabled'); " + super.preDecorateOnSuccessScript(script);
  26. }
  27. @Override
  28. public CharSequence preDecorateOnFailureScript(CharSequence script) {
  29. return "$('" + selector + "').removeAttr('disabled'); " + super.preDecorateOnFailureScript(script);
  30. }
  31. }

Report this snippet  

You need to login to post a comment.