You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2015/11/09 22:42:14 UTC

wicket git commit: WICKET-6029 Make Border's methods consistent with commit f14e03f

Repository: wicket
Updated Branches:
  refs/heads/wicket-7.x 98a2189d6 -> aec47fcae


WICKET-6029 Make Border's methods consistent with commit f14e03f


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/aec47fca
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/aec47fca
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/aec47fca

Branch: refs/heads/wicket-7.x
Commit: aec47fcae826272889e6d069d80a0565d59043f8
Parents: 98a2189
Author: Andrea Del Bene <ad...@apache.org>
Authored: Mon Nov 9 22:41:38 2015 +0100
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Mon Nov 9 22:41:38 2015 +0100

----------------------------------------------------------------------
 .../wicket/markup/html/border/Border.java       | 43 +++++++++++++++++---
 1 file changed, 37 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/aec47fca/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
index 5125bd5..322b507 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
@@ -221,7 +221,19 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes
 	@Override
 	public Border addOrReplace(final Component... children)
 	{
-		getBodyContainer().addOrReplace(children);
+		for (Component component : children)
+		{
+			if (component == body)
+			{
+				// in this case we do not want to redirect to body
+				// container but to border's old remove.
+				super.addOrReplace(component);
+			}
+			else 
+			{
+				getBodyContainer().addOrReplace(component);				
+			}
+		}
 		return this;
 	}
 
@@ -230,10 +242,9 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes
 	{
 		if (component == body)
 		{
-			// when the user calls foo.add(getBodyContainer()) this method will be called with it to
-			// clear body container's old parent, in which case we do not want to redirect to body
+			// in this case we do not want to redirect to body
 			// container but to border's old remove.
-			super.remove(body);
+			removeFromBorder(component);
 		}
 		else
 		{
@@ -242,10 +253,21 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes
 		return this;
 	}
 
+	
+	
 	@Override
 	public Border remove(final String id)
 	{
-		getBodyContainer().remove(id);
+		if (body.getId().equals(id))
+		{
+			// in this case we do not want to redirect to body
+			// container but to border's old remove.
+			super.remove(id);
+		}
+		else
+		{
+			getBodyContainer().remove(id);
+		}
 		return this;
 	}
 
@@ -259,7 +281,16 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes
 	@Override
 	public Border replace(final Component replacement)
 	{
-		getBodyContainer().replace(replacement);
+		if (body.getId().equals(replacement.getId()))
+		{
+			// in this case we do not want to redirect to body
+			// container but to border's old remove.
+			replaceInBorder(replacement);
+		}
+		else
+		{
+			getBodyContainer().replace(replacement);
+		}
 		return this;
 	}
 


Re: wicket git commit: WICKET-6029 Make Border's methods consistent with commit f14e03f

Posted by andrea del bene <an...@gmail.com>.

On 10/11/2015 09:45, Martin Grigorov wrote:
> On Mon, Nov 9, 2015 at 10:42 PM, <ad...@apache.org> wrote:
>
>> +               if (body.getId().equals(replacement.getId()))
>>
> Why not identity check as the other places?
>
> This may fail if there are two Borders with the same id in the hierarchy.
> Very unlikely to replace their bodies though.
Good point. Initially it was an identity check as the others, but then I 
thought that in this case it might not have sense. With an identity 
check we are telling something like "replace body with...itself?". So I 
thought that checking for the same body's id is more rational. But as 
you said it's very unlikely that somebody will replace body component....
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>


Re: wicket git commit: WICKET-6029 Make Border's methods consistent with commit f14e03f

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Nov 9, 2015 at 10:42 PM, <ad...@apache.org> wrote:

> +               if (body.getId().equals(replacement.getId()))
>

Why not identity check as the other places?

This may fail if there are two Borders with the same id in the hierarchy.
Very unlikely to replace their bodies though.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov