Friday, June 1, 2012

Wicket Handling JavaScript Events

Wicket provides useful classes for handling of JavaScript events such as:
  1. onMouseOver
  2. onMouseOut
  3. onFocus
  4. onBlur
  5. onKeyUp
  6. onKeyDown
  7. etc.
Full list of events here www.w3schools.com/jsref/dom_obj_event.asp
To handle a JavaScript event e.g. onMouseOver on an element on the page hierarchy, add the following:

add(new AjaxEventBehavior("onMouseOver") {
    protected void onEvent(AjaxRequestTarget target) {
        // do something.....
    }
}
);

AjaxFormSubmitBehavior can be used in a similar way to achieve the same results when it is necessary to capture information for processing (e.g. real time search)

Also note that for very chatty Ajax events like onKeyUp & onKeyDown, setThrottleDelay can be used.

No comments:

Post a Comment