I have issue that have strange steps. I have ajax behave rendered on Head render stage
final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
protected void respond(final AjaxRequestTarget target) {
boolean undoEn = getRequest().getQueryParameters().getParameterValue("undoEn").toBoolean();
if (undoEn) {
mSaveButton.setEnabled(true);
target.add(mSaveButton);
}
}
};
public String getCallbackName() {
return "saveButtonVisibilityToggle";
}
@Override
public void renderHead(IHeaderResponse response) {
String script = getCallbackName() + " = function (e) { Wicket.Ajax.ajax({\"u\": \"" + behave.getCallbackUrl() + " + &undoEn=\"+e+\"\" });}";
response.render(OnDomReadyHeaderItem.forScript(script));
}
Everything works well this behave called every time node changed in tinyMCE editor
settings.addCustomSetting(" setup: function(editor) {" +
" editor.on('NodeChange', function(e) {" +
" editor.save();" +
getCallbackName() + "(editor.undoManager.hasUndo())" +
" });" +
" }");
But sometimes when i leave browser tab, change few tabs (chrome) then use other app for few minutes, and turn back to our tab, ajax url have accidently appeared in browser url.
http://localhost:8080/wicket/bookmarkable/com.tac.kulik.pages.SomePage?3-1.IBehaviorListener.0-contentPanel&entityId=2+++&undoEn=true
this is also quite strange that instead normap parameter pass it's ++++ signs added
by the way this sighns recognized as "2 " so for some reason '+' changed to whitespace
UPDATE 1 Using @svenmeier answer i've page start's infinite loop refreshing. with logs
org.apache.wicket.core.request.mapper.StalePageException: A request to
page '[Page class = x.x.x.CardPage, id = 25, render count = 1]' has been
made with stale 'renderCount'. The page will be re-rendered.
and really for some reason behave link has renderCount 1, but form has 0. the request from browser jquery-1.12.4-ver-1476216952000.js:10254 XHR finished loading: GET "http://localhost:8080/wicket/bookmarkable/com.tac.pages.ca…?4-0.IBehaviorListener.0-contentPanel&cardId=1&_=1476873175645&undoEn=true"
I ve add some set of JS to prevent cicling refreshing, But i'we still has Stale exception
"if (editor.undoManager.hasUndo()) { " +
" console.debug('Behave called ');" +
behave.getCallbackScript() +
" }" +
this is my behave
final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
protected void respond(final AjaxRequestTarget target) {
log.info("Behave called");
boolean undoEn = getRequest().getQueryParameters().getParameterValue("undoEn").toBoolean();
if (undoEn) {
mSaveButton.setEnabled(true);
target.add(mSaveButton);
}
}
//
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
String undoEn = "return {'undoEn': editor.undoManager.hasUndo()};";
attributes.getDynamicExtraParameters().add(undoEn);
}
};
And there is no difference, it could be behave without any realization, page behaviour the same((
final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
@Override
protected void respond(AjaxRequestTarget target) {
}
};