public void onSubmit()
{
labelModel.setObject("std btn was clicked");
}
}.setDefaultFormProcessing(false);
button.add(new InputBehavior(new KeyType[] { KeyType.b }, EventType.click));
form.add(new InputBehavior(new KeyType[] { KeyType.Ctrl, KeyType.a }, EventType.submit));
form.add(button);
Button button2 = new Button("button2").setDefaultFormProcessing(false);
button2.add(new AjaxEventBehavior("onClick")
{
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target)
{
labelModel.setObject("ajax was fired");
target.add(label);
}
});
button2.add(new InputBehavior(new KeyType[] { KeyType.c }));
form.add(button2);
Link<String> link = new Link<String>("link")
{
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void onClick()
{
labelModel.setObject("link clicked");
}
};
form.add(new TextField<String>("text", new Model<String>("")).add(new InputBehavior(
new KeyType[] { KeyType.Ctrl, KeyType.f }, EventType.focus)
{
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected Boolean getDisable_in_input()
{
// remember this for all input behaviors, elsewise the shortcut will be triggered in
// the text field
// not a problem if combination of keys though
return true;
}
}));
link.add(new InputBehavior(new KeyType[] { KeyType.e }));
add(link);
final Form<Void> ajaxContainer = new Form<Void>("ajaxContainer");
add(ajaxContainer);
// Counter
final Label counterLabel = new Label("counter", new PropertyModel<Integer>(this, "counter"));
counterLabel.setOutputMarkupId(true);
ajaxContainer.add(counterLabel);
// Increase
Button increaseButton = new AjaxButton("increase")
{
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form)
{
counter++;
target.add(counterLabel);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form)
{
}
};
increaseButton.add(new InputBehavior(new KeyType[] { KeyType.Up }, EventType.click));
ajaxContainer.add(increaseButton);
// Refresh
Button refreshButton = new AjaxButton("refresh")
{