This is an automated email from the ASF dual-hosted git repository. theigl pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push: new 2e3e95f WICKET-6963 Use singletons for PanelMarkupSourcingStrategy (#503) 2e3e95f is described below commit 2e3e95f919c9eb08eca8898da7d3b3103a497879 Author: Thomas Heigl <thomas.he...@gmail.com> AuthorDate: Wed Mar 23 18:07:00 2022 +0100 WICKET-6963 Use singletons for PanelMarkupSourcingStrategy (#503) --- .../apache/wicket/markup/html/border/BorderPanel.java | 2 +- .../wicket/markup/html/form/FormComponentPanel.java | 2 +- .../org/apache/wicket/markup/html/panel/Panel.java | 2 +- .../html/panel/PanelMarkupSourcingStrategy.java | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/BorderPanel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/BorderPanel.java index c194333..997372a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/BorderPanel.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/BorderPanel.java @@ -92,7 +92,7 @@ public abstract class BorderPanel extends Panel @Override protected IMarkupSourcingStrategy newMarkupSourcingStrategy() { - return new PanelMarkupSourcingStrategy(true); + return PanelMarkupSourcingStrategy.get(true); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java index 5fe284f..50c4846 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java @@ -146,7 +146,7 @@ public abstract class FormComponentPanel<T> extends FormComponent<T> implements @Override protected IMarkupSourcingStrategy newMarkupSourcingStrategy() { - return new PanelMarkupSourcingStrategy(false); + return PanelMarkupSourcingStrategy.get(false); } @Override diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java index 1520c07..ba3d9d9 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java @@ -81,7 +81,7 @@ public abstract class Panel extends WebMarkupContainer implements IQueueRegion @Override protected IMarkupSourcingStrategy newMarkupSourcingStrategy() { - return new PanelMarkupSourcingStrategy(false); + return PanelMarkupSourcingStrategy.get(false); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/PanelMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/PanelMarkupSourcingStrategy.java index 50c80c7..fe0418f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/PanelMarkupSourcingStrategy.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/PanelMarkupSourcingStrategy.java @@ -33,10 +33,29 @@ import org.apache.wicket.markup.MarkupStream; */ public class PanelMarkupSourcingStrategy extends AssociatedMarkupSourcingStrategy { + private static final PanelMarkupSourcingStrategy PANEL_INSTANCE = new PanelMarkupSourcingStrategy( + false); + private static final PanelMarkupSourcingStrategy BORDER_INSTANCE = new PanelMarkupSourcingStrategy( + true); + // False for Panel and true for Border components. private final boolean allowWicketComponentsInBodyMarkup; /** + * @param allowWicketComponentsInBodyMarkup + * {@code false} for Panel and {@code true} for Border components. If Panel then the + * body markup should only contain raw markup, which is ignored (removed), but no + * Wicket Component. With Border components, the body markup will be associated with + * the Body Component. + * + * @return A singleton of the strategy + */ + public static PanelMarkupSourcingStrategy get(final boolean allowWicketComponentsInBodyMarkup) + { + return allowWicketComponentsInBodyMarkup ? BORDER_INSTANCE : PANEL_INSTANCE; + } + + /** * Constructor. * * @param wicketTagName