I’m using Vaadin 7.6.1 and Viritin 1.4.2
I’ve provided a fully functional minimal example below, which generates a table with 2 rows, which contain id 1 and 2. When the “Update Rows” button is clicked the table should repopulate with id 2 and 4 - but does not.
Is call ing resetLazyList() the correct way to cause the table to update or is this a bug?
import java.util.LinkedList;
import java.util.List;
import org.vaadin.viritin.LazyList.CountProvider;
import org.vaadin.viritin.SortableLazyList.SortablePagingProvider;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTable;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.VerticalLayout;
public class CutdownExample extends VerticalLayout implements View
{
private long base = 0;
public CutdownExample()
{
}
@Override
public void enter(ViewChangeEvent event)
{
ViritinProvider provider = new ViritinProvider();
final MTable<Entity> mTable = new MTable<Entity>(provider, provider).withProperties("id")
.withColumnHeaders("id");
mTable.setSizeFull();
MButton updateButton = new MButton("Update Rows").withListener(new ClickListener()
{
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event)
{
base += 2;
mTable.resetLazyList();
}
});
addComponent(updateButton);
addComponent(mTable);
setExpandRatio(mTable, 1f);
}
static final public class Entity
{
Long id;
public Entity(long base)
{
id = base;
}
public Long getId()
{
return id;
}
}
class ViritinProvider implements CountProvider, SortablePagingProvider<Entity>
{
private static final long serialVersionUID = 1L;
@Override
public List<Entity> findEntities(int firstRow, boolean sortAscending, String property)
{
List<Entity> list = new LinkedList<>();
list.add(new Entity(base));
list.add(new Entity(base + 1));
return list;
}
@Override
public int size()
{
return 2;
}
}
}