You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/02/06 09:52:00 UTC
[29/38] git commit: WICKET-4926 fixed problem inside modal window;
simplified; not need for ajax reference
WICKET-4926 fixed problem inside modal window; simplified; not need for
ajax reference
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/311e0d29
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/311e0d29
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/311e0d29
Branch: refs/heads/reference-guide
Commit: 311e0d29a112aaecfb30191407e8df125d1a751f
Parents: e950657
Author: svenmeier <sv...@apache.org>
Authored: Sun Feb 3 12:57:20 2013 +0100
Committer: svenmeier <sv...@apache.org>
Committed: Sun Feb 3 12:57:20 2013 +0100
----------------------------------------------------------------------
.../markup/html/form/AbstractCheckSelector.java | 22 ++-
.../markup/html/form/AbstractCheckSelector.js | 118 ----------
.../wicket/markup/html/form/CheckBoxSelector.java | 21 +--
.../wicket/markup/html/form/CheckBoxSelector.js | 41 ----
.../markup/html/form/CheckGroupSelector.java | 44 ++---
.../wicket/markup/html/form/CheckGroupSelector.js | 48 ----
.../wicket/markup/html/form/CheckSelector.js | 169 +++++++++++++++
.../html/form/CheckboxMultipleChoiceSelector.java | 22 +--
.../html/form/CheckboxMultipleChoiceSelector.js | 45 ----
9 files changed, 209 insertions(+), 321 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.java
index 37ec8c4..158989a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.java
@@ -16,14 +16,17 @@
*/
package org.apache.wicket.markup.html.form;
+import java.util.Arrays;
+
+import org.apache.wicket.ajax.WicketEventJQueryResourceReference;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.HeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnLoadHeaderItem;
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
import org.apache.wicket.request.resource.ResourceReference;
-import org.apache.wicket.resource.CoreLibrariesContributor;
/**
* Base class for all Javascript-based "select-all" checkboxes. Provides a simple "select all"
@@ -43,7 +46,19 @@ public abstract class AbstractCheckSelector extends LabeledWebMarkupContainer
private static final long serialVersionUID = 1L;
private static final ResourceReference JS = new JavaScriptResourceReference(
- AbstractCheckSelector.class, "AbstractCheckSelector.js");
+ AbstractCheckSelector.class, "CheckSelector.js")
+ {
+
+ /**
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Iterable<? extends HeaderItem> getDependencies()
+ {
+ return Arrays.asList(JavaScriptHeaderItem.forReference(WicketEventJQueryResourceReference.get()));
+ };
+ };
/**
* Construct.
@@ -70,9 +85,8 @@ public abstract class AbstractCheckSelector extends LabeledWebMarkupContainer
@Override
public void renderHead(IHeaderResponse response)
{
- // make sure we have all the javascript we need
- CoreLibrariesContributor.contributeAjax(getApplication(), response);
response.render(JavaScriptHeaderItem.forReference(JS));
+
String findCheckboxes = getFindCheckboxesFunction().toString();
// initialize the selector
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js
deleted file mode 100644
index 2e2ab9c..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js
+++ /dev/null
@@ -1,118 +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.
- */
-
-// introduce a namespace
-if (typeof (Wicket.CheckboxSelector) === "undefined") {
- Wicket.CheckboxSelector = {};
-
- /**
- * Called in the onclick handler of the select-all-checkbox. Updates all
- * associated checkboxes by simulating a click on those that need to have
- * their state changed.
- *
- * @param newCheckedState
- * the state to which all checkboxes should be set
- * @param findCheckboxes
- * a function that returns an array containing the IDs of all
- * associated checkboxes
- */
- // adapted from AjaxFormChoiceComponentUpdatingBehavior
- Wicket.CheckboxSelector.updateAllCheckboxes = function(newCheckedState, findCheckboxes) {
- "use strict";
-
- var i,
- checkboxes = findCheckboxes();
- for (i in checkboxes) {
- var checkbox = checkboxes[i];
- if (checkbox.checked !== newCheckedState) {
- checkbox.click();
- }
- }
- };
-
- /**
- * Called in the onclick handlers of the associated checkboxes if the auto
- * update feature is active. Checks the state of all checkboxes - if all are
- * checked, the selector is checked too. Otherwise the selector is
- * unchecked.
- *
- * @param selectorId
- * the ID of the selector checkbox
- * @param findCheckboxes
- * a function that returns an array containing the IDs of all
- * associated checkboxes
- */
- Wicket.CheckboxSelector.updateSelectorState = function(selectorId, findCheckboxes) {
- "use strict";
-
- var i,
- checkboxes = findCheckboxes(),
- allChecked = true;
-
- for (i in checkboxes) {
- if (!(checkboxes[i].checked)) {
- allChecked = false;
- break;
- }
- }
- var selector = Wicket.$(selectorId);
- selector.checked = allChecked;
- };
-
- /**
- * Called in the onLoad event if the auto update feature is active. Attaches
- * an onclick handler to all associated checkboxes.
- *
- * @param selectorId
- * the ID of the selector checkbox
- * @param findCheckboxes
- * a function that returns an array containing the IDs of all
- * associated checkboxes
- */
- Wicket.CheckboxSelector.attachUpdateHandlers = function(selectorId, findCheckboxes) {
- "use strict";
-
- var i,
- checkboxes = findCheckboxes(),
- clickHandler = function() {
- Wicket.CheckboxSelector.updateSelectorState(selectorId, findCheckboxes);
- };
-
- for (i in checkboxes) {
- Wicket.Event.add(checkboxes[i], 'click', clickHandler);
- }
- // update selector state once to get the right initial state
- Wicket.CheckboxSelector.updateSelectorState(selectorId, findCheckboxes);
- };
-
- /**
- * Called in the onLoad event to initialize the selector checkbox.
- * @param selectorId
- * the ID of the selector checkbox
- * @param findCheckboxes
- * a function that returns an array containing the IDs of all
- * associated checkboxes
- */
- Wicket.CheckboxSelector.initializeSelector = function(selectorId, findCheckboxes) {
- "use strict";
-
- var selector = Wicket.$(selectorId);
- Wicket.Event.add(selector, 'click', function() {
- Wicket.CheckboxSelector.updateAllCheckboxes(selector.checked, findCheckboxes);
- });
- };
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.java
index da48dd5..46620d3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.java
@@ -19,10 +19,6 @@ package org.apache.wicket.markup.html.form;
import java.util.Arrays;
import org.apache.wicket.Component;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.request.resource.JavaScriptResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
/**
@@ -37,9 +33,6 @@ public class CheckBoxSelector extends AbstractCheckSelector
{
private static final long serialVersionUID = 1L;
- private final static ResourceReference JS = new JavaScriptResourceReference(
- CheckBoxSelector.class, "CheckBoxSelector.js");
-
/**
* Javascript array literal containing the markup IDs of the checkboxes we want to
* check/uncheck. Example: "['foo', 'bar', 'baz']". Generated by
@@ -56,25 +49,17 @@ public class CheckBoxSelector extends AbstractCheckSelector
public CheckBoxSelector(String id, CheckBox... boxes)
{
super(id);
- setOutputMarkupId(true);
+
checkBoxIdArrayLiteral = buildMarkupIdJSArrayLiteral(Arrays.asList(boxes));
}
@Override
protected CharSequence getFindCheckboxesFunction()
{
- return "Wicket.CheckboxSelector.Checkboxes.findCheckboxesFunction(" +
- checkBoxIdArrayLiteral + ")";
+ return String.format("Wicket.CheckboxSelector.getCheckboxesFunction(%s)",
+ checkBoxIdArrayLiteral);
}
- @Override
- public void renderHead(IHeaderResponse response)
- {
- super.renderHead(response);
- response.render(JavaScriptHeaderItem.forReference(JS));
- }
-
-
/**
* Builds a JavaScript array literal containing the markup IDs of the given components. Example:
* "['foo', 'bar', 'baz']".
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js
deleted file mode 100644
index 99cf777..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js
+++ /dev/null
@@ -1,41 +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.
- */
-// introduce a namespace, just to be nice
-if (typeof (Wicket.CheckboxSelector.Checkboxes) === "undefined") {
- Wicket.CheckboxSelector.Checkboxes = {};
- /**
- * Returns a closure that finds all checkboxes with the given IDs.
- *
- * @param checkBoxIDs
- * An array containing the markup IDs of all checkboxes this
- * selector should control.
- */
- Wicket.CheckboxSelector.Checkboxes.findCheckboxesFunction = function(checkBoxIDs) {
- "use strict";
-
- return function() {
- var i,
- result = [];
-
- for (i in checkBoxIDs) {
- var checkBox = Wicket.$(checkBoxIDs[i]);
- result.push(checkBox);
- }
- return result;
- };
- };
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.java
index f6ed362..67e4964 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.java
@@ -17,10 +17,6 @@
package org.apache.wicket.markup.html.form;
import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.request.resource.JavaScriptResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
/**
* Selects and deselects all Check components under the same CheckGroup as itself. Selection
@@ -40,9 +36,6 @@ public class CheckGroupSelector extends AbstractCheckSelector
/** */
private static final long serialVersionUID = 1L;
- private final static ResourceReference JS = new JavaScriptResourceReference(
- CheckGroupSelector.class, "CheckGroupSelector.js");
-
private CheckGroup<?> group;
/**
@@ -56,13 +49,6 @@ public class CheckGroupSelector extends AbstractCheckSelector
this(id, null);
}
- @Override
- public void renderHead(IHeaderResponse response)
- {
- super.renderHead(response);
- response.render(JavaScriptHeaderItem.forReference(JS));
- }
-
/**
* A Selector that will work with the given group.
*
@@ -74,8 +60,8 @@ public class CheckGroupSelector extends AbstractCheckSelector
public CheckGroupSelector(String id, CheckGroup<?> group)
{
super(id);
+
this.group = group;
- setOutputMarkupId(true);
}
private CheckGroup<?> getGroup()
@@ -90,19 +76,14 @@ public class CheckGroupSelector extends AbstractCheckSelector
}
@Override
- protected void onInitialize()
+ protected void onBeforeRender()
{
- // try and make sure the form we need outputs its markup id.
- super.onInitialize();
+ super.onBeforeRender();
+
CheckGroup<?> group = getGroup();
- if (group != null)
- {
- Form<?> form = group.getForm();
- if (form != null)
- {
- form.setOutputMarkupId(true);
- }
- }
+
+ // make sure the form we need outputs its markup id.
+ group.getForm().setOutputMarkupId(true);
}
@Override
@@ -119,6 +100,10 @@ public class CheckGroupSelector extends AbstractCheckSelector
}
}
+ /**
+ * Find all checkboxes in the containing form with the same input name as the {@link CheckGroup}
+ * .
+ */
@Override
protected CharSequence getFindCheckboxesFunction()
{
@@ -130,7 +115,10 @@ public class CheckGroupSelector extends AbstractCheckSelector
getPath() +
"] cannot find its parent CheckGroup. All CheckGroupSelector components must be a child of or below in the hierarchy of a CheckGroup component.");
}
- return "Wicket.CheckboxSelector.Group.findCheckboxesFunction('" +
- group.getForm().getRootForm().getMarkupId() + "','" + group.getInputName() + "')";
+
+ // we search the complete form because the CheckGroup might not output its markup tag or be
+ // located on a <wicket:container>
+ return String.format("Wicket.CheckboxSelector.findCheckboxesFunction('%s','%s')",
+ group.getForm().getMarkupId(), group.getInputName());
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js
deleted file mode 100644
index 21207fe..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js
+++ /dev/null
@@ -1,48 +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.
- */
-// introduce a namespace, just to be nice
-if (typeof (Wicket.CheckboxSelector.Group) === "undefined") {
- Wicket.CheckboxSelector.Group = {};
- /**
- * Returns a closure that finds all checkboxes associated with the given
- * CheckGroup.
- *
- * @param formId
- * The markup ID of the containing form (needed because the
- * selector might be outside the form)
- * @param groupName
- * The input name of the CheckGroup
- */
- Wicket.CheckboxSelector.Group.findCheckboxesFunction = function(formId, groupName) {
- "use strict";
-
- return function() {
- var result = [];
- var parentForm = Wicket.$(formId);
- var parentGroup = parentForm[groupName];
- if (parentGroup && parentGroup.length) {
- for ( var i = 0; i < parentGroup.length; i++) {
- var checkbox = parentGroup[i];
- result.push(checkbox);
- }
- } else if (parentGroup) {
- result.push(parentGroup);
- }
- return result;
- };
- };
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
new file mode 100644
index 0000000..8344eff
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+;(function (undefined) {
+
+ 'use strict';
+
+ if (typeof(Wicket.CheckboxSelector) === 'object') {
+ return;
+ }
+
+ Wicket.CheckboxSelector = {
+
+ /**
+ * Called in the onclick handler of the select-all-checkbox. Updates all
+ * associated checkboxes by simulating a click on those that need to have
+ * their state changed.
+ *
+ * @param newCheckedState
+ * the state to which all checkboxes should be set
+ * @param findCheckboxes
+ * a function that returns an array containing the IDs of all
+ * associated checkboxes
+ */
+ updateAllCheckboxes: function(newCheckedState, findCheckboxes) {
+
+ var i,
+ checkboxes = findCheckboxes();
+ for (i in checkboxes) {
+ var checkbox = checkboxes[i];
+ if (checkbox.checked !== newCheckedState) {
+ checkbox.click();
+ }
+ }
+ },
+
+ /**
+ * Called in the onclick handlers of the associated checkboxes if the auto
+ * update feature is active. Checks the state of all checkboxes - if all are
+ * checked, the selector is checked too. Otherwise the selector is
+ * unchecked.
+ *
+ * @param selectorId
+ * the ID of the selector checkbox
+ * @param findCheckboxes
+ * a function that returns an array containing the IDs of all
+ * associated checkboxes
+ */
+ updateSelectorState: function(selectorId, findCheckboxes) {
+ "use strict";
+
+ var i,
+ checkboxes = findCheckboxes(),
+ allChecked = true;
+
+ for (i in checkboxes) {
+ if (!(checkboxes[i].checked)) {
+ allChecked = false;
+ break;
+ }
+ }
+ var selector = document.getElementById(selectorId);
+ selector.checked = allChecked;
+ },
+
+ /**
+ * Called in the onLoad event if the auto update feature is active. Attaches
+ * an onclick handler to all associated checkboxes.
+ *
+ * @param selectorId
+ * the ID of the selector checkbox
+ * @param findCheckboxes
+ * a function that returns an array containing the IDs of all
+ * associated checkboxes
+ */
+ attachUpdateHandlers: function(selectorId, findCheckboxes) {
+ "use strict";
+
+ var i,
+ checkboxes = findCheckboxes(),
+ clickHandler = function() {
+ Wicket.CheckboxSelector.updateSelectorState(selectorId, findCheckboxes);
+ };
+
+ for (i in checkboxes) {
+ Wicket.Event.add(checkboxes[i], 'click', clickHandler);
+ }
+ // update selector state once to get the right initial state
+ Wicket.CheckboxSelector.updateSelectorState(selectorId, findCheckboxes);
+ },
+
+ /**
+ * Called in the onLoad event to initialize the selector checkbox.
+ * @param selectorId
+ * the ID of the selector checkbox
+ * @param findCheckboxes
+ * a function that returns an array containing the IDs of all
+ * associated checkboxes
+ */
+ initializeSelector: function(selectorId, findCheckboxes) {
+ "use strict";
+
+ var selector = document.getElementById(selectorId);
+ Wicket.Event.add(selector, 'click', function() {
+ Wicket.CheckboxSelector.updateAllCheckboxes(selector.checked, findCheckboxes);
+ });
+ },
+
+ /**
+ * Returns a closure that finds all checkboxes associated with the given
+ * CheckboxMultipleChoice.
+ *
+ * @param parentId
+ * The markup ID of the containing form component
+ */
+ findCheckboxesFunction: function(parentId, name) {
+ "use strict";
+
+ return function() {
+ var result = [];
+ var inputNodes = document.getElementById(parentId).getElementsByTagName('input');
+ for ( var i = 0; i < inputNodes.length; i++) {
+ var inputNode = inputNodes[i];
+ if (inputNode.name === name) {
+ result.push(inputNode);
+ }
+ }
+ return result;
+ };
+ },
+
+ /**
+ * Returns a closure that gets all checkboxes with the given IDs.
+ *
+ * @param checkBoxIDs
+ * An array containing the markup IDs of all checkboxes this
+ * selector should control.
+ */
+ getCheckboxesFunction: function(checkBoxIDs) {
+ "use strict";
+
+ return function() {
+ var i,
+ result = [];
+
+ for (i in checkBoxIDs) {
+ var checkBox = document.getElementById(checkBoxIDs[i]);
+ result.push(checkBox);
+ }
+ return result;
+ };
+ }
+ };
+
+})();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.java
index 7186f9f..deb4820 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.java
@@ -16,12 +16,6 @@
*/
package org.apache.wicket.markup.html.form;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.request.resource.JavaScriptResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-
-
/**
* A Javascript-based "Select All" checkbox component that works with {@link CheckBoxMultipleChoice}
* . By default, clicking on any of the controlled checkboxes automatically updates the state of the
@@ -34,9 +28,6 @@ public class CheckboxMultipleChoiceSelector extends AbstractCheckSelector
{
private static final long serialVersionUID = 1L;
- private final static ResourceReference JS = new JavaScriptResourceReference(
- CheckboxMultipleChoiceSelector.class, "CheckboxMultipleChoiceSelector.js");
-
private final CheckBoxMultipleChoice<?> choiceComponent;
/**
@@ -48,22 +39,15 @@ public class CheckboxMultipleChoiceSelector extends AbstractCheckSelector
public CheckboxMultipleChoiceSelector(String id, CheckBoxMultipleChoice<?> choiceComponent)
{
super(id);
+
this.choiceComponent = choiceComponent;
choiceComponent.setOutputMarkupId(true);
- setOutputMarkupId(true);
- }
-
- @Override
- public void renderHead(IHeaderResponse response)
- {
- super.renderHead(response);
- response.render(JavaScriptHeaderItem.forReference(JS));
}
@Override
protected CharSequence getFindCheckboxesFunction()
{
- return "Wicket.CheckboxSelector.Choice.findCheckboxesFunction('" +
- choiceComponent.getMarkupId() + "')";
+ return String.format("Wicket.CheckboxSelector.findCheckboxesFunction('%s', '%s')",
+ choiceComponent.getMarkupId(), choiceComponent.getInputName());
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/311e0d29/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js
deleted file mode 100644
index 823edff..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js
+++ /dev/null
@@ -1,45 +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.
- */
-// introduce a namespace, just to be nice
-if (typeof (Wicket.CheckboxSelector.Choice) === "undefined") {
- Wicket.CheckboxSelector.Choice = {};
-
- /**
- * Returns a closure that finds all checkboxes associated with the given
- * CheckboxMultipleChoice.
- *
- * @param parentChoiceId
- * The markup ID of the CheckboxMultipleChoise
- */
- // adapted from AjaxFormChoiceComponentUpdatingBehavior
- Wicket.CheckboxSelector.Choice.findCheckboxesFunction = function(parentChoiceId) {
- "use strict";
-
- return function() {
- var result = [];
- var inputNodes = Wicket.$(parentChoiceId).getElementsByTagName(
- 'input');
- for ( var i = 0; i < inputNodes.length; i++) {
- var inputNode = inputNodes[i];
- if (inputNode.id.indexOf(parentChoiceId + '-') >= 0) {
- result.push(inputNode);
- }
- }
- return result;
- };
- };
-}