Bugs item #1289425, was opened at 2005-09-13 08:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1289425&group_id=119783

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: core
Group: 1.0.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Arjan Zwaan (arjan81)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in ListView

Initial Comment:
In my case it's in the for-loop in the method 
internalOnBeginRequest().

This is the current code:

// 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 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);
   }
}

Because of the "final int index = firstIndex + i;" it'll go wrong 
when firstIndex is anything > 0, because i still starts at 0. In 
that case "ListItem item = (ListItem)get(Integer.toString
(index));" will return "null" and will result in a 
IndexOutOfBoundsException when calling "item = newItem
(index);".

I believe the code should be:
// Loop through the markup in this container for each item
for (int i = firstIndex ; i < size; i++) {

   // If this component does not already exist, populate it

   ListItem item = (ListItem)get(Integer.toString(i));

   if (item == null)  {
      // Create item for index
      item = newItem(i);
      // Add list item
      add(item);
      // Populate the list item
      onBeginPopulateItem(item);
      populateItem(item);
   }
}

The same probably goes for the method: onRender()
and in setStartIndex(final int startIndex) the "else-if" 
probably should be "else if (firstIndex >= getList().size())".
You probably want to check the method getViewSize() too.

Also PageableList in the contrib package has a same kind 
of index error: PageableList.get(int index), the first if-
statement should say: "if (index >= size())" right?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1289425&group_id=119783


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to