public BeanItemContainer<MyBean> getListaMyBean() {
List<Ciudad> lista = null;
try {
lista = this.getControl().getServiceControl()
.getListMyBean(this.getBeanOne());
} catch (ExcepcionDao e) {
e.printStackTrace();
}
BeanItemContainer<MyBean> cr = new BeanItemContainer<MyBean>(lista);
return cr;
}
then if list is null because no get value BeanItemContainer =null
but shows
23:34:00,455 [http-80-4]
DEBUG [http-80-4]
{rset-100020} ResultSet
com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.IllegalArgumentException: The collection passed to BeanItemContainer must not be null or empty
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1154)
at com.vaadin.ui.TabSheet.fireSelectedTabChange(TabSheet.java:772)
at com.vaadin.ui.TabSheet.setSelectedTab(TabSheet.java:498)
at com.vaadin.ui.TabSheet.changeVariables(TabSheet.java:564)
because it takes the null value and displays this message
As an addition, in 6.5 there is coming a new contstructor to BeanItemContainer which takes in both the list and class. With that you don’t have to do the null check that kim presented anymore. Hurray \o/
Kim already give you the code needed to do it right. You should check if the list is null or not, and choose the constructor according to that. Here’s the code you need, once again:
public BeanItemContainer<Unidad> getListaUnidad() {
List<Unidad> lista = null;
try {
lista = this.getControladorInventario().getServicioUnidad()
.getListaUnidad(this.getCiudadSeleccionada());
} catch (ExcepcionDao e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BeanItemContainer<Unidad> cu;
if(lista != null && !lista.isEmpty()){
cu = new BeanItemContainer<Unidad>(lista);
} else {
cu = new BeanItemContainer<Unidad>(Unidad.class);
}
return cu;
}