@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
{
super.updateAjaxAttributes(attributes);
IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
@Override
public CharSequence getSuccessHandler(Component component)
{
return "alert('Success');";
}
@Override
public CharSequence getBeforeSendHandler(Component component)
{
return "alert('Before ajax call');";
}
@Override
public CharSequence getFailureHandler(Component component)
{
return "alert('Failure');";
}
};
attributes.getAjaxCallListeners().add(ajaxCallListener);
List<CharSequence> urlArgumentMethods = attributes.getDynamicExtraParameters();
urlArgumentMethods.add("return {'htmlname': document.documentElement.tagName};");
urlArgumentMethods.add("return {'bodyname': document.body.tagName};");
}
});
add(new AjaxLink<Void>("failure-link")
{
@Override
public void onClick(AjaxRequestTarget target)
{
// Set the proper setting to execute ajax failure handler
// note: will be set until the "exception" link is clicked or the application is
// restarted
getApplication().getExceptionSettings().setAjaxErrorHandlingStrategy(
ExceptionSettings.AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);
throw new WicketRuntimeException("Failure link clicked");
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
{
super.updateAjaxAttributes(attributes);
IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
@Override
public CharSequence getBeforeHandler(Component component)
{
return "alert('Before ajax call');";
}