How do you get all items in a BeanItemContainer?

I’m trying to get all items in a BeanItemContainer. I’m only able to get beans that are visible in the UI but I need the ability to get beans that aren’t visible in the UI thus all items.

for (? itemId : container.getItemIds()) {
  ? item = container.getItem(itemId);
  // do something...

That code only gets visible items in the container. I need the ability to get non-visible as well from the container.

If you mean that you have some filters applied, then I think the only way is to subclass the container to access the getAllItemIds() method which is protected.

Hmm, I don’t know if you can trust the getAllItemIds method. Actually the property ist the real map for all entities and itemIds. Too bad it’s private and there is no getter.

Umm, why could you not trust it? After all, it’s used by most of the methods in AbstractInMemoryContainer. If there is some issue in getAllItemIds I think the whole container would be flaky.

Also, if you need access to the actual Item instead of just the item ID, you should make getUnfilteredItem(Object itemId) accessible too and use that to get the item.

Dear Colin did you use an ArrayList like
ArrayList beanlist = new ArrayList();
in order to collect your items?

That is one solution I could do and was doing but if I can just create a custom container and get all the beans in that container that will be better.

You are right, I double checked it. getAllItemIds() works fine :slight_smile:

Well, that would have been useful information. :slight_smile: