THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Add Javascript in serverside code using AjaxRequestTarget#appendJavascript
or #prependJavascript
.
And there's still the option to use an IAjaxCallDecorator
(example).
TODO: examples!
Adding a Wicket JS call to a component can be accomplished by adding the following Ajax behavior to a component (this example would only apply to a component that has an onblur event associated with it):
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 = (FormComponent) getEditorComponent();
c.processInput();
if (c.hasErrorMessage()) {
Serializable msg = c.getFeedbackMessage().getMessage();
// do something with the message
}
}
}
...
|