Author: dashorst Date: Sun Dec 24 05:40:47 2006 New Revision: 490018 URL: http://svn.apache.org/viewvc?view=rev&rev=490018 Log: WICKET-179 don't attach when not visible in hierarchy
Modified:
incubator/wicket/branches/wicket-1.2.x/wicket/src/main/java/wicket/markup/html/list/ListView.java
Modified:
incubator/wicket/branches/wicket-1.2.x/wicket/src/main/java/wicket/markup/html/list/ListView.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.2.x/wicket/src/main/java/wicket/markup/html/list/ListView.java?view=diff&rev=490018&r1=490017&r2=490018
==============================================================================
---
incubator/wicket/branches/wicket-1.2.x/wicket/src/main/java/wicket/markup/html/list/ListView.java
(original)
+++
incubator/wicket/branches/wicket-1.2.x/wicket/src/main/java/wicket/markup/html/list/ListView.java
Sun Dec 24 05:40:47 2006
@@ -530,60 +530,63 @@
*/
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;
+ else
+ {
+ // Automatically rebuild all ListItems
before rendering the
+ // list view
+ removeAll();
+ }
- // If this component does not already exist,
populate it
- ListItem item =
(ListItem)get(Integer.toString(index));
- if (item == null)
+ // Loop through the markup in this container
for each item
+ for (int i = 0; i < size; i++)
{
- // Create item for index
- item = newItem(index);
+ // Get index
+ final int index = firstIndex + i;
- // Add list item
- add(item);
+ // If this component does not already
exist, populate it
+ ListItem item =
(ListItem)get(Integer.toString(index));
+ if (item == null)
+ {
+ // Create item for index
+ item = newItem(index);
+
+ // Add list item
+ add(item);
- // Populate the list item
- onBeginPopulateItem(item);
- populateItem(item);
+ // Populate the list item
+ onBeginPopulateItem(item);
+ populateItem(item);
+ }
}
}
- }
- else
- {
- removeAll();
+ else
+ {
+ removeAll();
+ }
}
}
