All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.ydn.wicket.wicketconsole.behavior.CtrlEnterSubmitBehavior Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package ru.ydn.wicket.wicketconsole.behavior;

import org.apache.wicket.ajax.attributes.AjaxCallListener;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
import org.apache.wicket.markup.html.form.Form;

public class CtrlEnterSubmitBehavior extends AjaxFormSubmitBehavior
{
	private static final String EVENT_TYPE = "keypress";
	private static final String CHECK_CTRL_ENTER_SCRIPT = "var e = attrs.event; return (e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey;";

	public CtrlEnterSubmitBehavior(Form form)
	{
		super(form, EVENT_TYPE);
	}

	public CtrlEnterSubmitBehavior()
	{
		super(EVENT_TYPE);
	}

	@Override
	protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
		super.updateAjaxAttributes(attributes);
		attributes.setPreventDefault(false);
		attributes.getAjaxCallListeners().add(new AjaxCallListener().onPrecondition(CHECK_CTRL_ENTER_SCRIPT));
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy