-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WICKET-7123 default form submit can now be set one per form (#971)
* WICKET-7123 default form submit can now be set one per form (not form hierarchy) * WICKET-7123 fixed missing license header * WICKET-7123 removed jquery from form script * WICKET-7123 added example for default form submit used in form hierarchy * WICKET-7123 replaced wrong element (td) * WICKET-7123 Minor improvements to the example/demo page Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> --------- Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> Co-authored-by: Martin Tzvetanov Grigorov <[email protected]>
- Loading branch information
Showing
10 changed files
with
416 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
.../src/test/java/org/apache/wicket/markup/html/form/FormHierarchyDefaultButtonTestPage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<html> | ||
<body> | ||
<form wicket:id="parentForm"> | ||
|
||
<input type="text" wicket:id="parentInput"/> | ||
|
||
<button wicket:id="parentSubmit"></button> | ||
|
||
<form wicket:id="childForm"> | ||
<input type="text" wicket:id="childInput"/> | ||
|
||
<button wicket:id="childSubmit"></button> | ||
</form> | ||
</form> | ||
</body> | ||
</html> |
69 changes: 69 additions & 0 deletions
69
.../src/test/java/org/apache/wicket/markup/html/form/FormHierarchyDefaultButtonTestPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
package org.apache.wicket.markup.html.form; | ||
|
||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior; | ||
import org.apache.wicket.markup.html.WebPage; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
public class FormHierarchyDefaultButtonTestPage extends WebPage { | ||
/** | ||
* For serialization. | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
|
||
public final Form<Void> parentForm; | ||
public final Form<Void> childForm; | ||
public final Button parentSubmit; | ||
public final Button childSubmit; | ||
public final TextField<?> parentInput; | ||
public final TextField<?> childInput; | ||
|
||
/** | ||
* Construct. | ||
*/ | ||
public FormHierarchyDefaultButtonTestPage() { | ||
parentForm = new Form<>("parentForm"); | ||
add(parentForm); | ||
|
||
parentInput = new TextField<>("parentInput"); | ||
parentForm.add(parentInput); | ||
|
||
parentSubmit = new Button("parentSubmit"); | ||
parentSubmit.add(new AjaxFormSubmitBehavior(parentForm, "click") { | ||
|
||
@Override | ||
protected void onSubmit(AjaxRequestTarget target) { | ||
Assertions.fail("Shouldn't be called"); | ||
} | ||
|
||
}); | ||
parentForm.setDefaultButton(parentSubmit); | ||
parentForm.add(parentSubmit); | ||
|
||
childForm = new Form<>("childForm"); | ||
parentForm.add(childForm); | ||
|
||
childInput = new TextField<>("childInput"); | ||
childForm.add(childInput); | ||
|
||
childSubmit = new Button("childSubmit"); | ||
childForm.setDefaultButton(childSubmit); | ||
childForm.add(childSubmit); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../java/org/apache/wicket/markup/html/form/FormHierarchyDefaultButtonTestPage_expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<html> | ||
<head><script type="text/javascript" src="../resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-3.7.1.js"></script> | ||
<script type="text/javascript" src="../resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery.js"></script> | ||
<script type="text/javascript" id="wicket-ajax-debug-enable"> | ||
/*<![CDATA[*/ | ||
Wicket.Log.enabled=true; | ||
/*]]>*/ | ||
</script> | ||
<script type="text/javascript" id="wicket-ajax-base-url"> | ||
/*<![CDATA[*/ | ||
Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.markup.html.form.FormHierarchyDefaultButtonTestPage?0"; | ||
/*]]>*/ | ||
</script> | ||
<script type="text/javascript"> | ||
/*<![CDATA[*/ | ||
Wicket.Event.add(window, "domready", function(event) { | ||
Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.form.FormHierarchyDefaultButtonTestPage?0-1.0-parentForm-parentSubmit","m":"POST","c":"parentSubmit2","f":"parentForm1","sc":"parentSubmit","e":"click"});; | ||
Wicket.Event.add('childForm4', 'keypress', function(event) { var b = document.getElementById('childSubmit3');if (window.getComputedStyle(b).visibility === 'hidden') return;if (event.which == 13) {event.stopPropagation();event.preventDefault();if (b != null && b.onclick != null && typeof (b.onclick) != 'undefined') {var r = Wicket.bind(b.onclick, b)();if (r != false) b.click();} else {b.click();}return false;};});; | ||
Wicket.Event.add('parentForm1', 'keypress', function(event) { var b = document.getElementById('parentSubmit2');if (window.getComputedStyle(b).visibility === 'hidden') return;if (event.which == 13) {event.stopPropagation();event.preventDefault();if (b != null && b.onclick != null && typeof (b.onclick) != 'undefined') {var r = Wicket.bind(b.onclick, b)();if (r != false) b.click();} else {b.click();}return false;};});; | ||
Wicket.Event.publish(Wicket.Event.Topic.AJAX_HANDLERS_BOUND); | ||
;}); | ||
/*]]>*/ | ||
</script> | ||
</head><body> | ||
<form wicket:id="parentForm" id="parentForm1" method="post" action="./org.apache.wicket.markup.html.form.FormHierarchyDefaultButtonTestPage?0-1.-parentForm"><div id="parentForm1_hf_0" hidden="" class="hidden-fields"></div> | ||
|
||
<input type="text" wicket:id="parentInput" value="" name="parentInput"/> | ||
|
||
<button wicket:id="parentSubmit" name="parentSubmit" id="parentSubmit2"></button> | ||
|
||
<div wicket:id="childForm" id="childForm4"> | ||
<input type="text" wicket:id="childInput" value="" name="childForm:childInput"/> | ||
|
||
<button wicket:id="childSubmit" name="childForm:childSubmit" id="childSubmit3"></button> | ||
</div> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.