EDIT: One solution was initializing the fields of the bean i’m passing to the list when the list happends to be empty or null.
Should it matter that the values themselves are null? In another place i pass values intermingled with null with no problem.
Also i used this passing a bean with null fields tehnnique somewhere else, and it didn’t raise any problems, although it is triggering the update from a subwindow button event, instead of pushing the same button that loads the layout in the first place - maybe that matters too.
I have a table that is updated when the data changes on the server, after a button is clicked whose event makes the verification that it changed first. The problem with it is that the data can be be a null or empty list, in which case, i initialize a list and put a mock object in it for the table to display empty. The problem is that after the data changes, and the list returned isn’t null anymore, it wouldn’t refresh the table like the usual. If the first list that’s passed to the container data source isn’t a mock one, it updates just fine.
It is notable though that if i change view to something else when this happends, then come back (though objects from the server side are reused), the tables reload from the server side, and the problem table is displaying the new data.
Going to add the relevant code i’m using to do this:
Normal initialization.
if(globalTable == null)
globalTable = new ExtractionsFrequencyTable();
List<NrsUnicityFrequency> list = returnMatchGroupFrequency(this.nrs);
if (list != null && !list.isEmpty()) {
localTable = new ExtractionsFrequencyTable(list);
localTable.setPageLength(1);
}
else {
list = new ArrayList<NrsUnicityFrequency>();
list.add(new NrsUnicityFrequency());
localTable = new ExtractionsFrequencyTable(list);
localTable.setPageLength(1);
}
if (localTable != null) {
drawContent(globalTable, localTable, new VerticalLayout());
}
Somewhere else in the code, where it runs after i check the data changed.
The repaints do not work, the add/remove works of course, but generates other problems
if (list != null && !list.isEmpty()) {
if (unicity.localTable != null) {
unicity.localTable
.setContainerDataSource(new BeanItemContainer<NrsUnicityFrequency>(
list));
unicity.localTable
.setVisibleColumns(ExtractionsFrequencyTable.NATURAL_COL_ORDER);
// unicity.localTable.requestRepaint();
// unicity.localTable.detach();
// unicity.localTable.attach();
// unicity.localTable.requestRepaintAll();
// unicity.localTable.requestRepaintRequests();
// unicity.mainLayout.removeComponent(unicity.localTable);
// unicity.mainLayout.addComponent(unicity.localTable);
}
} else {
list = new ArrayList<NrsUnicityFrequency>();
list.add(new NrsUnicityFrequency());
unicity.localTable = new ExtractionsFrequencyTable(list);
unicity.localTable.setPageLength(1);
}