You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2015/11/25 21:48:45 UTC

[2/2] wicket git commit: WICKET-6044 AjaxFormChoiceComponentUpdatingBehavior: Duplicate input values according to WICKET-5948

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/659c47d5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/659c47d5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/659c47d5

Branch: refs/heads/wicket-6.x
Commit: 659c47d52bb12f780ee4540becc9bcdcc926558a
Parents: 8d75090
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Nov 25 18:55:58 2015 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Wed Nov 25 21:47:17 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/659c47d5/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 4d5a492..bd4f4e3 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
@@ -64,9 +60,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;
 
 	/**
@@ -78,14 +71,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);
@@ -97,14 +82,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/659c47d5/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;
-		};
-	}
-})();