Adding Javascript confirm dialog to AjaxButton

by kinabalu on July 19, 2009

If you have an AJAX button in your form, a nice way of adding javascript is to use an IAjaxCallDecorator

form.add(new AjaxButton("removeButton") {
 
    @Override 
    protected IAjaxCallDecorator getAjaxCallDecorator() {
        return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()) {
        private static final long serialVersionUID = 1L;
 
            @Override
            public CharSequence preDecorateScript(CharSequence script) {
                return "if(!confirm('Are you sure you want to delete this?')) return false;" + script;
            }
        };
    }
}

Similar Posts:

Share this:
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Slashdot
  • Technorati

{ 1 trackback }

Onglets Dynamiques : Etape 7 – Corrections | NooCodeCommit
July 27, 2009 at 12:58 am

{ 0 comments… add one now }

Leave a Comment

Next post: