I am looking to prevent updates based on a specific JavaScript condition using AjaxSelfUpdatingTimerBehavior.
WebMarkupContainer messagesWmc = new WebMarkupContainer( "messagesWmc" ) ;
messagesWmc.setOutputMarkupId( true ) ;
messagesWmc.add(
new AjaxSelfUpdatingTimerBehavior(Duration.seconds( 5 )) {
private static final long serialVersionUID = -103345839370452326L;
@Override
protected void onPostProcessTarget(AjaxRequestTarget target) {
target.appendJavaScript( "restoreMessages();" );
super.onPostProcessTarget(target);
}
});
This code snippet generates the following output:
Wicket.Event.add(window, "load", function(event) {
Wicket.Timer.set('messagesId.0', function(){Wicket.Ajax.ajax({"u":"./messages?8-1.0-form-messagesWmc","c":"messagesId"});}, 5000);;
;});
What I am trying to achieve is:
Wicket.Event.add(window, "load", function(event) {
Wicket.Timer.set('messagesId.0', function(){**if(someCondition)** Wicket.Ajax.ajax({"u":"./messages?8-1.0-form-messagesWmc","c":"messagesId"});}, 5000);;
;});