Vaadin 6.8 - BeanItemContainer "missing" beans

I am having an odd problem- I’ve added my contents from a database query- the intermediate list which I’ve debugged and HAS all the correct beans, does not always show all the items in the container?!!??

Pseudo code sequence:

[code]

  1. Retrieve bean from DAO, which returns List
  2. List verified to contain the correct contents
  3. add to BeanItemContainer as follows:
    if (null != items)
    for (Object item : items)
    container.addItem(item);
    Have used: addAll(Collection), same result. Broke it out into a for…loop to debug. Same results.

[/code]It is odd, since the beans are all correctly formed, apparently, since the DAO creates a list of beans fine. Yet, they do not get into the container… at least not always.

It is always consistent what gets left out, not sure how to proceed from here to resolve. The data is the List yet for some reason the BeanItemContainer ignores some entries.

Suggestions welcome. I’m sure this is me missing something obvious, so please don’t be shy and point it out! :stuck_out_tongue: Thanks in advance.

My suspicion: the item IDs for some of the items are seen as the same (check your equals(…) and hashCode() methods) so the container considers the items are already there.
If you cannot change those methods to be suitable for BeanItemContainer, use BeanContainer instead of BeanItemContainer and either use explicit item IDs or an ID resolver for the container.

You could also trace execution into container.addItem(…) to investigate this deeper.

Thanks again Henri.

Tried BeanContainer today and it was more messy than what I currently have, so I went back to a BeanItemContainer sub-class.

I was barking up that tree already(bean ID’s), but forgot that the container depend on them,
Thanks I’ll check it out.

As an aside, the classes and factories I’ve built can reduce a CRUD application to a few lines, the only important “addition” is creating a factory class. I’ll probably put this out as an addon once all the current bugs are worked out.

The main thing the framework does is remove the need for anonymous inner classes, which I find inelegant, verbose and opaque. I’ve never felt they were a good design feature, they are a “poor man’s” lambda function, but they don’t really do the job at all. Interestingly James Gosling admitted in an interview, the original intention was to have Java as a functional programming language, but they ran out of time and so we got anonymous methods & classes.

I am seriously investigating Groovy. Done one tiny Vaadin project in it, and frankly going back to Java was painful.

Thanks again for the excellent support.

Just tested the “correct” equals() and hasCode() methods, I’d forgotten I’d removed them in an earlier restructure. So the underlying “raw” Object ones were being used.

Once valid methods for that class were created, everything worked like a charm.

Thanks for pointing out the obvious with such tact and elegance.