Repository: wicket Updated Branches: refs/heads/wicket-7.x f8e35bde9 -> 8c33eeab9
WICKET-6044 AjaxFormChoiceComponentUpdatingBehavior: Duplicate input values according to WICKET-5948 Simplify AjaxFormChoiceComponentUpdatingBehavior. Since WICKET-5948 wicket-ajax.js collects all form elements children Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/d7a0b52f Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/d7a0b52f Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/d7a0b52f Branch: refs/heads/wicket-7.x Commit: d7a0b52f47f8871cde6e6ad8b0ba5c573252917a Parents: f8e35bd Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Wed Nov 25 18:55:58 2015 +0200 Committer: Sven Meier <[email protected]> Committed: Wed Nov 25 21:45:10 2015 +0100 ---------------------------------------------------------------------- ...AjaxFormChoiceComponentUpdatingBehavior.java | 22 +----- .../AjaxFormChoiceComponentUpdatingBehavior.js | 71 -------------------- 2 files changed, 1 insertion(+), 92 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/d7a0b52f/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java index feaa75c..2b10d1e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java @@ -20,15 +20,11 @@ import org.apache.wicket.Component; import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.ajax.attributes.AjaxCallListener; import org.apache.wicket.ajax.attributes.AjaxRequestAttributes; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.markup.html.form.CheckBoxMultipleChoice; import org.apache.wicket.markup.html.form.CheckGroup; import org.apache.wicket.markup.html.form.FormComponent; import org.apache.wicket.markup.html.form.RadioChoice; import org.apache.wicket.markup.html.form.RadioGroup; -import org.apache.wicket.request.resource.JavaScriptResourceReference; -import org.apache.wicket.request.resource.ResourceReference; /** * This is a Ajax Component Update Behavior that is meant for choices/groups that are not one @@ -49,9 +45,6 @@ import org.apache.wicket.request.resource.ResourceReference; public abstract class AjaxFormChoiceComponentUpdatingBehavior extends AjaxFormComponentUpdatingBehavior { - private static final ResourceReference CHOICE_JS = new JavaScriptResourceReference( - AjaxFormChoiceComponentUpdatingBehavior.class, "AjaxFormChoiceComponentUpdatingBehavior.js"); - private static final long serialVersionUID = 1L; /** @@ -63,14 +56,6 @@ public abstract class AjaxFormChoiceComponentUpdatingBehavior extends } @Override - public void renderHead(Component component, IHeaderResponse response) - { - super.renderHead(component, response); - - response.render(JavaScriptHeaderItem.forReference(CHOICE_JS)); - } - - @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); @@ -82,14 +67,9 @@ public abstract class AjaxFormChoiceComponentUpdatingBehavior extends @Override public CharSequence getPrecondition(Component component) { - return String.format("return Wicket.Choice.acceptInput('%s', attrs)", - getFormComponent().getInputName()); + return "return attrs.event.target.name === " + getFormComponent().getInputName(); } }); - - attributes.getDynamicExtraParameters().add( - String.format("return Wicket.Choice.getInputValues('%s', attrs)", - getFormComponent().getInputName())); } /** http://git-wip-us.apache.org/repos/asf/wicket/blob/d7a0b52f/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js deleted file mode 100644 index f2da088..0000000 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ - -/* - * Wicket Choice Ajax updates. - * - * @author svenmeier - */ - -;(function (undefined) { - "use strict"; - - // introduce a namespace - if (typeof (Wicket.Choice) === "undefined") { - Wicket.Choice = {}; - - /** - * Is a change accepted. - * - * @param name input name of choice - * @param attrs ajax attributes - */ - Wicket.Choice.acceptInput = function(name, attrs) { - - var srcElement = attrs.event.target; - - return (srcElement.name === name); - }; - - /** - * Get all checked input values. - * - * @param name input name of choice - * @param attrs ajax attributes - */ - Wicket.Choice.getInputValues = function(name, attrs) { - var result = [], srcElement = attrs.event.target; - - var inputNodes = Wicket.$(attrs.c).getElementsByTagName("input"); - for (var i = 0 ; i < inputNodes.length ; i ++) { - var inputNode = inputNodes[i]; - - if (inputNode.name !== name) { - continue; - } - if (!inputNode.checked) { - continue; - } - - var value = inputNode.value; - result.push({ name: name, value: value }); - } - - return result; - }; - } -})();
