Author: ivaynberg
Date: Mon Sep  3 21:03:43 2007
New Revision: 572505

URL: http://svn.apache.org/viewvc?rev=572505&view=rev
Log:
clear cached item count before render. this value might be cached before render 
is started - for example when visibility of something is checked and 
getitemscount() is called - but the items might change between then and render 
time so it is not safe to cache it during that time period

Modified:
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/repeater/AbstractPageableView.java

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/repeater/AbstractPageableView.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/repeater/AbstractPageableView.java?rev=572505&r1=572504&r2=572505&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/repeater/AbstractPageableView.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/repeater/AbstractPageableView.java
 Mon Sep  3 21:03:43 2007
@@ -25,18 +25,14 @@
 
 
 /**
- * An abstract repeater view that provides paging functionality to its
- * subclasses.
+ * An abstract repeater view that provides paging functionality to its 
subclasses.
  * <p>
- * The view is populated by overriding the
- * <code>getItemModels(int offset, int count)</code> method and providing an
- * iterator that returns models for items in the current page. The
- * AbstractPageableView builds the items that will be rendered by looping over
- * the models and calling the
- * <code>newItem(String id, int index, IModel model)</code> to generate the
- * child item container followed by <code>populateItem(Component item)</code>
- * to let the user populate the newly created item container with with custom
- * components.
+ * The view is populated by overriding the <code>getItemModels(int offset, int 
count)</code>
+ * method and providing an iterator that returns models for items in the 
current page. The
+ * AbstractPageableView builds the items that will be rendered by looping over 
the models and
+ * calling the <code>newItem(String id, int index, IModel model)</code> to 
generate the child item
+ * container followed by <code>populateItem(Component item)</code> to let the 
user populate the
+ * newly created item container with with custom components.
  * </p>
  * 
  * @see 
org.apache.wicket.extensions.markup.html.repeater.refreshing.RefreshingView
@@ -49,8 +45,8 @@
 
 {
        /**
-        * Keeps track of the number of items we show per page. The default is
-        * Integer.MAX_VALUE which effectively disables paging.
+        * Keeps track of the number of items we show per page. The default is 
Integer.MAX_VALUE which
+        * effectively disables paging.
         */
        private int itemsPerPage = Integer.MAX_VALUE;
 
@@ -61,9 +57,9 @@
 
        /**
         * <code>cachedItemCount</code> is used to cache the call to
-        * <code>internalGetItemCount()</code> for the duration of the request
-        * because that call can potentially be expensive ( a select count 
query )
-        * and so we do not want to execute it multiple times.
+        * <code>internalGetItemCount()</code> for the duration of the request 
because that call can
+        * potentially be expensive ( a select count query ) and so we do not 
want to execute it
+        * multiple times.
         */
        private int cachedItemCount;
 
@@ -85,8 +81,8 @@
 
 
        /**
-        * This method retrieves the subset of models for items in the current 
page
-        * and allows RefreshingView to generate items.
+        * This method retrieves the subset of models for items in the current 
page and allows
+        * RefreshingView to generate items.
         * 
         * @return iterator over models for items in the current page
         */
@@ -109,6 +105,12 @@
                super.onAttach();
        }
 
+       protected void onPopulate()
+       {
+               clearCachedItemCount();
+               super.onPopulate();
+       }
+
        /**
         * Returns an iterator over models for items in the current page
         * 
@@ -163,8 +165,7 @@
        }
 
        /**
-        * Sets the maximum number of items to show per page. The current page 
will
-        * also be set to zero
+        * Sets the maximum number of items to show per page. The current page 
will also be set to zero
         * 
         * @param items
         */
@@ -241,8 +242,8 @@
                int page = currentPage;
 
                /*
-                * trim current page if its out of bounds this can happen if 
items are
-                * added/deleted between requests
+                * trim current page if its out of bounds this can happen if 
items are added/deleted between
+                * requests
                 */
 
                if (page > 0 && page >= getPageCount())
@@ -333,8 +334,8 @@
        // 
/////////////////////////////////////////////////////////////////////////
 
        /**
-        * Iterator adapter that makes sure only the specified max number of 
items
-        * can be accessed from its delegate.
+        * Iterator adapter that makes sure only the specified max number of 
items can be accessed from
+        * its delegate.
         */
        private static class CappedIteratorAdapter implements Iterator
        {


Reply via email to