You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2010/11/15 01:43:17 UTC

svn commit: r1035110 - /wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java

Author: ivaynberg
Date: Mon Nov 15 00:43:16 2010
New Revision: 1035110

URL: http://svn.apache.org/viewvc?rev=1035110&view=rev
Log:
caching for isVisibleInHieararchy
Issue: WICKET-3166

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=1035110&r1=1035109&r2=1035110&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Mon Nov 15 00:43:16 2010
@@ -430,6 +430,16 @@ public abstract class Component
 	};
 
 	/**
+	 * Keeps metadata about the visibility state of the component
+	 * 
+	 * The states are: null - not calculated, true and false
+	 */
+	private static final MetaDataKey<Boolean> VISIBLE_IN_HIERARCHY_CACHE_KEY = new MetaDataKey<Boolean>()
+	{
+		private static final long serialVersionUID = 1L;
+	};
+
+	/**
 	 * Keeps metadata about the enabled state of the component
 	 * 
 	 * The states are: null - not calculated, true and false
@@ -2138,12 +2148,21 @@ public abstract class Component
 	 */
 	public final boolean isVisibleInHierarchy()
 	{
-		Component parent = getParent();
-		if (parent != null && !parent.isVisibleInHierarchy())
+		Boolean state = getMetaData(VISIBLE_IN_HIERARCHY_CACHE_KEY);
+		if (state == null)
 		{
-			return false;
+			Component parent = getParent();
+			if (parent != null && !parent.isVisibleInHierarchy())
+			{
+				state = false;
+			}
+			else
+			{
+				state = determineVisibility();
+			}
+			setMetaData(VISIBLE_IN_HIERARCHY_CACHE_KEY, state);
 		}
-		return determineVisibility();
+		return state;
 	}
 
 	/**