Author: knopp
Date: Thu Dec 21 15:23:45 2006
New Revision: 489497

URL: http://svn.apache.org/viewvc?view=rev&rev=489497
Log:
getModelObject() is not called when listview is not visible in hierarchy

Modified:
    
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/list/ListView.java

Modified: 
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/list/ListView.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/list/ListView.java?view=diff&rev=489497&r1=489496&r2=489497
==============================================================================
--- 
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/list/ListView.java
 (original)
+++ 
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/list/ListView.java
 Thu Dec 21 15:23:45 2006
@@ -540,57 +540,60 @@
        @SuppressWarnings("unchecked")
        protected void internalOnAttach()
        {
-               // Get number of items to be displayed
-               final int size = getViewSize();
-               if (size > 0)
+               if (isVisibleInHierarchy())
                {
-                       if (getReuseItems())
+                       // Get number of items to be displayed
+                       final int size = getViewSize();
+                       if (size > 0)
                        {
-                               // Remove all ListItems no longer required
-                               final int maxIndex = firstIndex + size;
-                               for (final Iterator iterator = iterator(); 
iterator.hasNext();)
+                               if (getReuseItems())
                                {
-                                       // Get next child component
-                                       final ListItem child = 
(ListItem)iterator.next();
-                                       if (child != null)
+                                       // Remove all ListItems no longer 
required
+                                       final int maxIndex = firstIndex + size;
+                                       for (final Iterator iterator = 
iterator(); iterator.hasNext();)
                                        {
-                                               final int index = 
child.getIndex();
-                                               if (index < firstIndex || index 
>= maxIndex)
+                                               // Get next child component
+                                               final ListItem child = 
(ListItem)iterator.next();
+                                               if (child != null)
                                                {
-                                                       iterator.remove();
+                                                       final int index = 
child.getIndex();
+                                                       if (index < firstIndex 
|| index >= maxIndex)
+                                                       {
+                                                               
iterator.remove();
+                                                       }
                                                }
                                        }
                                }
+                               else
+                               {
+                                       // Automatically rebuild all ListItems 
before rendering the
+                                       // list view
+                                       removeAll();
+                               }
+       
+                               // Loop through the markup in this container 
for each item
+                               for (int i = 0; i < size; i++)
+                               {
+                                       // Get index
+                                       final int index = firstIndex + i;
+       
+                                       // If this component does not already 
exist, populate it
+                                       ListItem<T> item = 
(ListItem<T>)get(Integer.toString(index));
+                                       if (item == null)
+                                       {
+                                               // Create item for index
+                                               item = newItem(index);
+       
+                                               // Populate the list item
+                                               onBeginPopulateItem(item);
+                                               populateItem(item);
+                                       }
+                               }
                        }
                        else
                        {
-                               // Automatically rebuild all ListItems before 
rendering the
-                               // list view
                                removeAll();
                        }
-
-                       // Loop through the markup in this container for each 
item
-                       for (int i = 0; i < size; i++)
-                       {
-                               // Get index
-                               final int index = firstIndex + i;
-
-                               // If this component does not already exist, 
populate it
-                               ListItem<T> item = 
(ListItem<T>)get(Integer.toString(index));
-                               if (item == null)
-                               {
-                                       // Create item for index
-                                       item = newItem(index);
-
-                                       // Populate the list item
-                                       onBeginPopulateItem(item);
-                                       populateItem(item);
-                               }
-                       }
-               }
-               else
-               {
-                       removeAll();
                }
        }
 


Reply via email to