Showing posts with label AjaxcallDecorator. Show all posts
Showing posts with label AjaxcallDecorator. Show all posts

July 14, 2010

Ajax call delay in wicket

When we add any ajax behavior for any wicket component (i.e. AjaxFormComponentUpdatingBehavior.. usually any Behavior of type AjaxEventBehavior ), make sure that override getAjaxCallDecorator() method and let users know that if any ajax failures(ajax time out, network problems etc) by using decorateOnFailureScript(CharSequence script) method in that Decorator class(i.e. AjaxCallDecorator... etc).

Example code:


component.add(new AjaxFormChoiceUpdatingBehavior(){
    @Override
   protected IAjaxCallDecorator getAjaxCallDecorator() {
    return new AjaxCallDecorator(){
     @Override
     public CharSequence decorateOnFailureScript(
       CharSequence script) {
      return "alert('There is a problem with ajax call')"
        + script;
     }
    };
   }
    @Override
   protected void onUpdate(AjaxRequestTarget target) {
    // code goes here ... when component gets updated.    
   }
   });
 


Bottom line is that be careful while handling ajax calls. :)