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:33 UTC
svn commit: r1035111 -
/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
Author: ivaynberg
Date: Mon Nov 15 00:43:32 2010
New Revision: 1035111
URL: http://svn.apache.org/viewvc?rev=1035111&view=rev
Log:
caching for isVisibleInHieararchy()
Issue: WICKET-3166
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java?rev=1035111&r1=1035110&r2=1035111&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java Mon Nov 15 00:43:32 2010
@@ -82,10 +82,10 @@ import org.slf4j.LoggerFactory;
* <ul>
* <li><b>Construction </b>- A Component is constructed with the Java language new operator.
* Children may be added during construction if the Component is a MarkupContainer.
- *
+ *
* <li><b>onInitialize </b>- The {@link #onInitialize()} method is called when a path from this
- * component to its parent has been established, usually after the component has been added to
- * its parent.
+ * component to its parent has been established, usually after the component has been added to its
+ * parent.
*
* <li><b>Request Handling </b>- An incoming request is processed by a protocol request handler such
* as WicketServlet. An associated Application object creates Session, Request and Response objects
@@ -696,6 +696,17 @@ public abstract class Component implemen
private static final long serialVersionUID = 1L;
};
+ /**
+ * 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;
+ };
+
+
/** Component flags. See FLAG_* for possible non-exclusive flag values. */
private int flags = FLAG_VISIBLE | FLAG_ESCAPE_MODEL_STRINGS | FLAG_VERSIONED | FLAG_ENABLED |
FLAG_IS_RENDER_ALLOWED | FLAG_VISIBILITY_ALLOWED;
@@ -2212,13 +2223,21 @@ public abstract class Component implemen
*/
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;
}
/**