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 2013/02/03 13:16:52 UTC
git commit: WICKET-4926 fixed problem inside modal window; simplified;
not need for ajax reference
Updated Branches:
refs/heads/wicket-1.5.x df44952fb -> 7efa1eed5
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/7efa1eed
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7efa1eed
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7efa1eed
Branch: refs/heads/wicket-1.5.x
Commit: 7efa1eed59cf6eceb2e91abb76b5e64f04864c9e
Parents: df44952
Author: svenmeier <sv...@apache.org>
Authored: Sun Feb 3 13:14:50 2013 +0100
Committer: svenmeier <sv...@apache.org>
Committed: Sun Feb 3 13:14:50 2013 +0100
----------------------------------------------------------------------
.../markup/html/form/AbstractCheckSelector.java | 5 +-
.../markup/html/form/AbstractCheckSelector.js | 106 ---------
.../wicket/markup/html/form/CheckBoxSelector.java | 20 +--
.../wicket/markup/html/form/CheckBoxSelector.js | 37 ----
.../markup/html/form/CheckGroupSelector.java | 43 ++---
.../wicket/markup/html/form/CheckGroupSelector.js | 46 ----
.../wicket/markup/html/form/CheckSelector.js | 169 +++++++++++++++
.../html/form/CheckboxMultipleChoiceSelector.java | 19 +--
.../html/form/CheckboxMultipleChoiceSelector.js | 44 ----
9 files changed, 193 insertions(+), 296 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/7efa1eed/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 ecd7a52..7d7e925 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,7 +16,6 @@
*/
package org.apache.wicket.markup.html.form;
-import org.apache.wicket.ajax.WicketAjaxReference;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.markup.html.IHeaderResponse;
@@ -42,7 +41,7 @@ public abstract class AbstractCheckSelector extends LabeledWebMarkupContainer
private static final long serialVersionUID = 1L;
private static final ResourceReference JS = new PackageResourceReference(
- AbstractCheckSelector.class, "AbstractCheckSelector.js");
+ AbstractCheckSelector.class, "CheckSelector.js");
/**
* Construct.
@@ -71,8 +70,8 @@ public abstract class AbstractCheckSelector extends LabeledWebMarkupContainer
{
// make sure we have all the javascript we need
response.renderJavaScriptReference(WicketEventReference.INSTANCE);
- response.renderJavaScriptReference(WicketAjaxReference.INSTANCE);
response.renderJavaScriptReference(JS);
+
String findCheckboxes = getFindCheckboxesFunction().toString();
// initialize the selector
http://git-wip-us.apache.org/repos/asf/wicket/blob/7efa1eed/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 5958598..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js
+++ /dev/null
@@ -1,106 +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 selectorId
- * the ID of the selector checkbox
- * @param findCheckboxes
- * a function that returns an array containing the IDs of all
- * associated checkboxes
- */
- // adapted from AjaxFormChoiceComponentUpdatingBehavior
- Wicket.CheckboxSelector.updateAllCheckboxes = function(newCheckedState, findCheckboxes) {
- var 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) {
- var checkboxes = findCheckboxes();
- var allChecked = true;
- for (i in checkboxes) {
- if (!(checkboxes[i].checked)) {
- allChecked = false;
- break;
- }
- }
- var selector = wicketGet(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) {
- var checkboxes = findCheckboxes();
- for (i in checkboxes) {
- Wicket.Event.add(checkboxes[i], 'click', function() {
- Wicket.CheckboxSelector.updateSelectorState(selectorId,
- findCheckboxes);
- });
- }
- // 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) {
- var selector = wicketGet(selectorId);
- Wicket.Event.add(selector, 'click', function() {
- Wicket.CheckboxSelector.updateAllCheckboxes(selector.checked,
- findCheckboxes);
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/7efa1eed/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 4f440dc..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,9 +19,6 @@ package org.apache.wicket.markup.html.form;
import java.util.Arrays;
import org.apache.wicket.Component;
-import org.apache.wicket.markup.html.IHeaderResponse;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
/**
@@ -36,9 +33,6 @@ public class CheckBoxSelector extends AbstractCheckSelector
{
private static final long serialVersionUID = 1L;
- private final static ResourceReference JS = new PackageResourceReference(
- 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
@@ -55,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.renderJavaScriptReference(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/7efa1eed/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 39c6850..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js
+++ /dev/null
@@ -1,37 +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 parentChoiceId
- * An array containing the markup IDs of all checkboxes this
- * selector should control.
- */
- Wicket.CheckboxSelector.Checkboxes.findCheckboxesFunction = function(checkBoxIDs) {
- return function() {
- var result = new Array();
- for (i in checkBoxIDs) {
- var checkBox = wicketGet(checkBoxIDs[i]);
- result.push(checkBox)
- }
- return result;
- }
- };
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/7efa1eed/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 4876f25..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,9 +17,6 @@
package org.apache.wicket.markup.html.form;
import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.markup.html.IHeaderResponse;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
/**
* Selects and deselects all Check components under the same CheckGroup as itself. Selection
@@ -39,9 +36,6 @@ public class CheckGroupSelector extends AbstractCheckSelector
/** */
private static final long serialVersionUID = 1L;
- private final static ResourceReference JS = new PackageResourceReference(
- CheckGroupSelector.class, "CheckGroupSelector.js");
-
private CheckGroup<?> group;
/**
@@ -55,13 +49,6 @@ public class CheckGroupSelector extends AbstractCheckSelector
this(id, null);
}
- @Override
- public void renderHead(IHeaderResponse response)
- {
- super.renderHead(response);
- response.renderJavaScriptReference(JS);
- }
-
/**
* A Selector that will work with the given group.
*
@@ -73,8 +60,8 @@ public class CheckGroupSelector extends AbstractCheckSelector
public CheckGroupSelector(String id, CheckGroup<?> group)
{
super(id);
+
this.group = group;
- setOutputMarkupId(true);
}
private CheckGroup<?> getGroup()
@@ -89,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
@@ -118,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()
{
@@ -129,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/7efa1eed/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 64d01f4..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js
+++ /dev/null
@@ -1,46 +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) {
- return function() {
- var result = new Array();
- var parentForm = wicketGet(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/7efa1eed/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/7efa1eed/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 70e58da..af93f98 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,9 +16,6 @@
*/
package org.apache.wicket.markup.html.form;
-import org.apache.wicket.markup.html.IHeaderResponse;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
/**
@@ -33,9 +30,6 @@ public class CheckboxMultipleChoiceSelector extends AbstractCheckSelector
{
private static final long serialVersionUID = 1L;
- private final static ResourceReference JS = new PackageResourceReference(
- CheckboxMultipleChoiceSelector.class, "CheckboxMultipleChoiceSelector.js");
-
private final CheckBoxMultipleChoice<?> choiceComponent;
/**
@@ -47,22 +41,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.renderJavaScriptReference(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/7efa1eed/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 0dd7ea6..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js
+++ /dev/null
@@ -1,44 +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) {
- return function() {
- var result = new Array();
- var inputNodes = wicketGet(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;
- }
- };
-}