You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Jeremy Thomerson (JIRA)" <ji...@apache.org> on 2010/06/16 03:22:25 UTC

[jira] Resolved: (WICKET-2909) ListView removeLink method should remove items from list based on item index

     [ https://issues.apache.org/jira/browse/WICKET-2909?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeremy Thomerson resolved WICKET-2909.
--------------------------------------

    Fix Version/s: 1.4.10
                   1.5-M1
       Resolution: Fixed

> ListView removeLink method should remove items from list based on item index
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-2909
>                 URL: https://issues.apache.org/jira/browse/WICKET-2909
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.9
>            Reporter: Clint Checketts
>            Assignee: Jeremy Thomerson
>            Priority: Minor
>             Fix For: 1.4.10, 1.5-M1
>
>         Attachments: quickstart.tar.gz
>
>
> In org.apache.wicket.markup.html.list.ListView the removeLink() method removes and object from the underlying list using the modelObject. instead it should remove using the item.getIndex().  
> Reason: if the listview's model contains several nulls, and the clicked item's object is null then the first null would get removed instead of the entry at the item that was actually clicked.
> Instead of:  'final int oldIndex = getList().indexOf(item.getModelObject());' use the passed in item.getIndex()
> Example:
> public void onClick()
> 			{
> 				addStateChange(new Change()
> 				{
> 					private static final long serialVersionUID = 1L;
> 					final int oldIndex = item.getIndex()); <- Change here ///////////////////////////////
> 					final T removedObject = item.getModelObject();
> 					@Override
> 					public void undo()
> 					{
> 						((List<T>)getList()).add(oldIndex, removedObject);
> 					}
> 				});
> 				item.modelChanging();
> 				// Remove item and invalidate listView
> 				getList().remove(oldIndex);   <- Change here ///////////////////////////////
> 				ListView.this.modelChanged();
> 				ListView.this.removeAll();
> 			}
> I spoke with Jeremy Thomerson about this. Please assign to him. The moveUpLink and MoveDownLink are similarly affected.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.