You can use an AjaxFormComponentUpdatingBehavior("keyup") and override
the getAjaxCallDecorator method.
Example:
myLMC.add(new AjaxFormComponentUpdatingBehavior("keyup") {
onUpdate() {
// your logic
}
getAjaxCallDecorator() {
return new AjaxCallDecorator() {
decorateScript(script) {
return "if (pressedKey == 'K') { " + script + "}";
}
};
}
});
Of course you will need a more complex JavaScript logic but this example
only shows how to add a conditional callback to your ajax behavior :)
Istvan De wrote:
Hi!
How to receive a javascript keypress event from a ListMultipleChoice?
Basically I'd need to have a callback (on certain keys like enter, and
arrow keys) with the currently selected items.
I've tried AjaxFormComponentUpdatingBehavior, I've got two problems
with it:
- How to have this callback only on certain keys, not any key?
- When the arrow keys are used, the callback is called *before* the
actual moving of the selection is done in the browser, so I cannot
detect the newly selected item. (this is a JavaScript limitation
afaik, but maybe this can be worked around by sending the currently
selected item+the code of the pressed key)
Any ideas?
Best regards,
Istvan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]