Hi all,

I configure into Apache Syncope the possibility to close ModalWindow with ESC 
key press event.

public class CloseOnESCBehavior extends AbstractDefaultAjaxBehavior {

    private static final long serialVersionUID = 5826308247642534260L;
    private ModalWindow modalWindow;

    public CloseOnESCBehavior(ModalWindow modalWindow) {
        this.modalWindow = modalWindow;

    private static final String PRE_JS = "$(document).ready(function() {\n"
            + "$(document).bind('keyup', function(evt) {\n"
            + "    if (evt.keyCode == 27){\n";

    private static final String POST_JS = "\n evt.preventDefault();\n"
            + "evt.stopImmediatePropagation();\n"
            + "    }\n"
            + "  });\n"
            + "});";

    protected void respond(final AjaxRequestTarget target) {

    protected String findIndicatorId() {
        return null;

    public void renderHead(final Component component, final IHeaderResponse 
response) {

In the modal page:

add(new CloseOnESCBehavior(window));

It work correctly with Chrome and Safari. With Firefox, if I press the ESC key 
twice quickly before the window closes the console return an error:

ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Could not find 
root <ajax-response> element



Dott. Marco Di Sabatino Di Diodoro
Tel. +39 3939065570

Tirasa S.r.l.
Viale D'Annunzio 267 - 65127 Pescara
Tel +39 0859116307 / FAX +39 0859111173

Apache Syncope PPMC Member

Reply via email to