Repository: wicket Updated Branches: refs/heads/WICKET-6347-detachable-renderers [created] 0bc929d71
WICKET-6347 added #detach() to all renderers Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0bc929d7 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0bc929d7 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0bc929d7 Branch: refs/heads/WICKET-6347-detachable-renderers Commit: 0bc929d71865f052e895fd0918ea297acc7086fa Parents: 3179d34 Author: Sven Meier <svenme...@apache.org> Authored: Mon Mar 27 17:27:20 2017 +0200 Committer: Sven Meier <svenme...@apache.org> Committed: Mon Mar 27 17:27:20 2017 +0200 ---------------------------------------------------------------------- .../wicket/markup/html/form/AbstractChoice.java | 8 ++++++++ .../wicket/markup/html/form/IChoiceRenderer.java | 15 ++++++++++++--- .../ajax/markup/html/AjaxEditableChoiceLabel.java | 3 +++ .../html/autocomplete/AutoCompleteBehavior.java | 7 +++++++ .../html/autocomplete/AutoCompleteTextField.java | 8 ++++++++ .../html/autocomplete/IAutoCompleteRenderer.java | 11 +++++++++-- .../extensions/markup/html/form/palette/Palette.java | 2 ++ .../markup/html/form/select/IOptionRenderer.java | 12 ++++++++++-- .../markup/html/form/select/SelectOptions.java | 8 ++++++++ 9 files changed, 67 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java index 523116e..fd1cacf 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java @@ -501,4 +501,12 @@ public abstract class AbstractChoice<T, E> extends FormComponent<T> "This class does not support type-conversion because it is performed " + "exclusively by the IChoiceRenderer assigned to this component"); } + + @Override + protected void onDetach() + { + renderer.detach(); + + super.onDetach(); + }; } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-core/src/main/java/org/apache/wicket/markup/html/form/IChoiceRenderer.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/IChoiceRenderer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/IChoiceRenderer.java index c8345d4..5fcc14e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/IChoiceRenderer.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/IChoiceRenderer.java @@ -18,8 +18,8 @@ package org.apache.wicket.markup.html.form; import java.util.List; +import org.apache.wicket.model.IDetachable; import org.apache.wicket.model.IModel; -import org.apache.wicket.util.io.IClusterable; /** * Renders one choice. Separates the 'id' values used for internal representation from 'display @@ -30,7 +30,7 @@ import org.apache.wicket.util.io.IClusterable; * @param <T> * The model object type */ -public interface IChoiceRenderer<T> extends IClusterable +public interface IChoiceRenderer<T> extends IDetachable { /** * Get the value for displaying to an end user. @@ -70,4 +70,13 @@ public interface IChoiceRenderer<T> extends IClusterable * @return A choice from the list that has this {@code id} */ T getObject(String id, IModel<? extends List<? extends T>> choices); -} + + /** + * Override when needed. + */ + @Override + default void detach() + { + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java index 2afe6cf..221a42f 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java @@ -324,6 +324,9 @@ public class AjaxEditableChoiceLabel<T> extends AjaxEditableLabel<T> { choices.detach(); } + + renderer.detach(); + super.onDetach(); } } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteBehavior.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteBehavior.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteBehavior.java index 02472ac..5f5453a 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteBehavior.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteBehavior.java @@ -19,6 +19,7 @@ package org.apache.wicket.extensions.ajax.markup.html.autocomplete; import java.util.Iterator; import org.apache.wicket.Application; +import org.apache.wicket.Component; import org.apache.wicket.request.IRequestCycle; import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.cycle.RequestCycle; @@ -129,4 +130,10 @@ public abstract class AutoCompleteBehavior<T> extends AbstractAutoCompleteBehavi * @return iterator over all possible choice objects */ protected abstract Iterator<T> getChoices(String input); + + @Override + public void detach(Component component) + { + renderer.detach(); + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteTextField.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteTextField.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteTextField.java index 79b86ea..70536e4 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteTextField.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteTextField.java @@ -307,4 +307,12 @@ public abstract class AutoCompleteTextField<T> extends TextField<T> { return renderer; } + + @Override + protected void onDetach() + { + renderer.detach(); + + super.onDetach(); + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/IAutoCompleteRenderer.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/IAutoCompleteRenderer.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/IAutoCompleteRenderer.java index c2d0a5f..55a0d6b 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/IAutoCompleteRenderer.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/IAutoCompleteRenderer.java @@ -16,8 +16,8 @@ */ package org.apache.wicket.extensions.ajax.markup.html.autocomplete; +import org.apache.wicket.model.IDetachable; import org.apache.wicket.request.Response; -import org.apache.wicket.util.io.IClusterable; /** * A renderer used to generate html output for the {@link AutoCompleteBehavior}. @@ -60,7 +60,7 @@ import org.apache.wicket.util.io.IClusterable; * @author Janne Hietamäki (jannehietamaki) * */ -public interface IAutoCompleteRenderer<T> extends IClusterable +public interface IAutoCompleteRenderer<T> extends IDetachable { /** * Render the html fragment for the given completion object. Usually the html is written out by @@ -94,4 +94,11 @@ public interface IAutoCompleteRenderer<T> extends IClusterable */ void renderFooter(Response response, int count); + /** + * Override when needed. + */ + @Override + default void detach() + { + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java index 5f8c5f5..93432f9 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java @@ -671,6 +671,8 @@ public class Palette<T> extends FormComponentPanel<Collection<T>> // an alternative might be to attach it to one of the subcomponents choicesModel.detach(); + choiceRenderer.detach(); + super.onDetach(); } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/IOptionRenderer.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/IOptionRenderer.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/IOptionRenderer.java index e641c57..1854a19 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/IOptionRenderer.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/IOptionRenderer.java @@ -16,8 +16,8 @@ */ package org.apache.wicket.extensions.markup.html.form.select; +import org.apache.wicket.model.IDetachable; import org.apache.wicket.model.IModel; -import org.apache.wicket.util.io.IClusterable; /** * @param <T> @@ -25,7 +25,7 @@ import org.apache.wicket.util.io.IClusterable; * @author Igor Vaynberg (ivaynberg) * */ -public interface IOptionRenderer<T> extends IClusterable +public interface IOptionRenderer<T> extends IDetachable { /** * Get the value for displaying to the user. @@ -45,4 +45,12 @@ public interface IOptionRenderer<T> extends IClusterable * @return model that will contain the value object */ IModel<T> getModel(T value); + + /** + * Override when needed. + */ + @Override + default void detach() + { + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/0bc929d7/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java ---------------------------------------------------------------------- diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java index e0d338e..fdf22c1 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java @@ -185,4 +185,12 @@ public class SelectOptions<T> extends RepeatingView tag.setType(TagType.OPEN); } } + + @Override + protected void onDetach() + { + renderer.detach(); + + super.onDetach(); + } }