IndexedContainer addItemAfter(null.... help [SOLVED]

Greetings Vaadin creators / users:

Kudos on the great framework. I love it.

I have a ListSelect of values and I have added up and down arrows to sort the contents of the list (since the values need to be user sorted).

Things seem to work pretty well until the item gets one value from the top, and when I press the up button, the value simply disappears. The method (see the code snip below) that is getting called is “addItemAfter(null, selectedValue)” and according to the javadoc, this should place the value as the first in the Container. I think this may be brokenness, but I need some confirmation.

Normally, this list will have one to ten items in it that need to be sorted by the user.

Any ideas on how to fix this / work arround this issue?

Thank you for the consideration and the time.

Here is my code for the “up” button:


selectedList = new ListSelect(null, selectedValues);
up = new Button("^", new Button.ClickListener()
		{

			public void buttonClick(ClickEvent event)
			{
				Object selectedValue = selectedList.getValue();
				if (selectedValue != null)
				{
					Container ds = selectedList.getContainerDataSource();
					if (ds instanceof IndexedContainer)
					{
						IndexedContainer ids = (IndexedContainer) ds;
						if (!ids.isFirstId(selectedValue))
						{
							Object o = ids.prevItemId(selectedValue);
							if (ids.isFirstId(o))
							{
								selectedValues.removeItem(selectedValue);
								ids.addItemAfter(null, selectedValue);
							}
							else
							{
								selectedValues.removeItem(selectedValue);
								ids.addItemAfter(ids.prevItemId(o), selectedValue);
							}
						}
					}
					getWindow().showNotification("ds : " + ds.getItemIds());
				}
			}
		});

It looks like addItemAfter(Object, Object) of IndexedContainer is not fulfilling the contract in Indexed with respect to this. I created the ticket
#4170
about the issue.

As a workaround, use addItemAt(0, Object).

Thanks! That worked perfectly - don’t know how I missed that method.