Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
...

	protected class MyBehavior extends AbstractDefaultAjaxBehavior {
		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			String js = "{wicketAjaxGet('" + getCallbackUrl() + "&'+this.name+'='+wicketEncode(this.value)); return false;}";
			tag.put("onblur", js);
		}

		@Override
		protected void respond(AjaxRequestTarget target) {
			FormComponent c = getMyComponent();
			c.processInput();
			if (c.hasErrorMessage()) {
				Serializable msg = c.getFeedbackMessage().getMessage();
				// do something with the message
			}
		}
	}

...

Adding ajax to events:

Code Block

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