Index: api/src/main/resources/org/hippoecm/frontend/widgets/on-enter-wait-then-click.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- api/src/main/resources/org/hippoecm/frontend/widgets/on-enter-wait-then-click.js (revision ) +++ api/src/main/resources/org/hippoecm/frontend/widgets/on-enter-wait-then-click.js (revision ) @@ -0,0 +1,33 @@ +/* + * Copyright 2015 Hippo B.V. (http://www.onehippo.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function ($) { + + var click = $('${clickId}'), + enter = $('${enterId}'); + + if (click.length > 0 && enter.length > 0) { + enter.keydown(function(e) { + if (e.which === 13) { + e.preventDefault(); + window.setTimeout(function() { + click.click(); + }, ${timeout}); + } + }); + } + +}(jQuery)); Index: api/src/main/java/org/hippoecm/frontend/widgets/NameUriField.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- api/src/main/java/org/hippoecm/frontend/widgets/NameUriField.java (revision 54720) +++ api/src/main/java/org/hippoecm/frontend/widgets/NameUriField.java (revision ) @@ -15,6 +15,9 @@ */ package org.hippoecm.frontend.widgets; +import java.util.Map; +import java.util.TreeMap; + import org.apache.commons.lang.StringUtils; import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -22,6 +25,9 @@ import org.apache.wicket.ajax.attributes.ThrottlingSettings; import org.apache.wicket.ajax.form.OnChangeAjaxBehavior; import org.apache.wicket.ajax.markup.html.AjaxLink; +import org.apache.wicket.behavior.Behavior; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.OnLoadHeaderItem; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.FormComponent; @@ -31,12 +37,16 @@ import org.apache.wicket.model.LoadableDetachableModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.util.template.PackageTextTemplate; import org.apache.wicket.util.time.Duration; import org.hippoecm.frontend.plugins.standards.list.resolvers.CssClass; import org.hippoecm.repository.api.StringCodec; public class NameUriField extends WebMarkupContainer { + private static final int NAME_UPDATE_TIMEOUT_LENGTH = 400; + private static final String ON_ENTER_WAIT_THEN_CLICK_JS = "on-enter-wait-then-click.js"; + private final IModel nameModel; private final IModel urlModel; @@ -82,8 +92,24 @@ } private FormComponent createNameComponent() { - FormComponent nameComponent = new TextField<>("name", nameModel); + final FormComponent nameComponent = new TextField<>("name", nameModel); nameComponent.setRequired(true); + + nameComponent.add(new Behavior() { + @Override + public void renderHead(final Component component, final IHeaderResponse response) { + + final PackageTextTemplate script = new PackageTextTemplate(NameUriField.class, ON_ENTER_WAIT_THEN_CLICK_JS); + final Map scriptParams = new TreeMap<>(); + scriptParams.put("enterId", "#" + nameComponent.getMarkupId()); + scriptParams.put("clickId", ".dialog-default-ok-button"); + scriptParams.put("timeout", Integer.toString(NAME_UPDATE_TIMEOUT_LENGTH)); + + response.render(OnLoadHeaderItem.forScript(script.asString(scriptParams))); + super.renderHead(component, response); + } + }); + nameComponent.add(new OnChangeAjaxBehavior() { @Override @@ -97,7 +123,8 @@ @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); - attributes.setThrottlingSettings(new ThrottlingSettings(NameUriField.this.getPath(), Duration.milliseconds(500))); + attributes.setThrottlingSettings(new ThrottlingSettings(NameUriField.this.getPath(), + Duration.milliseconds(NAME_UPDATE_TIMEOUT_LENGTH))); } }); nameComponent.setOutputMarkupId(true); Index: api/src/main/java/org/hippoecm/frontend/dialog/AbstractDialog.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- api/src/main/java/org/hippoecm/frontend/dialog/AbstractDialog.java (revision 54720) +++ api/src/main/java/org/hippoecm/frontend/dialog/AbstractDialog.java (revision ) @@ -16,7 +16,6 @@ package org.hippoecm.frontend.dialog; import java.io.Serializable; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -275,6 +274,12 @@ @Override protected void onSubmit() { handleSubmit(); + } + + @Override + protected Button decorate(final Button button) { + button.add(CssClass.append("dialog-default-ok-button")); + return super.decorate(button); } }; ok.setKeyType(KeyType.Enter);