On 01/23/2013 09:41 PM, Malte wrote:

I want write an AjaxEventBehavior that calls the server if an function
key is pressed. Im also need to know on serverside which key is

I'd tried it with this code:
public HomePage(final PageParameters parameters) {

    add(new AjaxEventBehavior("keydown"){
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {

            IAjaxCallListener listener = new AjaxCallListener(){
public CharSequence getPrecondition(Component component) {
                    //this javascript code evaluates wether an
                    //ajaxcall is necessary.
                    //Here only by keyocdes for F9 and F10
return "var keycode = Wicket.Event.keyCode(attrs.event);" +
                            "if ((keycode == 120) || (keycode == 121))" +
                            "    return true;" +
                            "else" +
                            "    return false;";

            //Append the pressed keycode to the ajaxrequest
.add("var eventKeycode = Wicket.Event.keyCode(attrs.event);" +
                     "return {keycode: eventKeycode};");

        protected void onEvent(AjaxRequestTarget target) {
            //Extract the keycode parameter from RequestCycle
            final Request request = RequestCycle.get().getRequest();
            final String jsKeycode = request.getRequestParameters()

            target.appendJavaScript("alert('from wicket ajax. you
pressed "+jsKeycode+"')");


My Problem is, that this blocking all Inputevents on all Inputfields
on the page. I find out, that the result false in the
Preconditionscript cause in a stopping of Eventhandling.

What can I do, that only the keys 120 and 121 result in an
ajaxcallback and leave all other keyevents untouched?

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to