Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
container property iteration
Hi:
How can I iterate over the properties of a container? (horizontal iteration), so I can later define variables to make the iteration over the data?....
I want to do something like this:
String a = item.getItemProperty(first_property).getValue().toString();
String b = item.getItemProperty(second_property).getValue().toString();
String c = item.getItemProperty(third_property).getValue().toString();
...
With all this variables I can later get their values with a normal BeanContainer iteration....
regards,
Hugo
Just get one Item from the Container and retrieve the set of PropertyIds via Item#getPropertyIds().
Tobias Demuth: Just get one Item from the Container and retrieve the set of PropertyIds via Item#getPropertyIds().
Thank you very much Tobias....
regards,
Hugo
Tobias Demuth: Just get one Item from the Container and retrieve the set of PropertyIds via Item#getPropertyIds().
Hi tobias...I've being using what you told me here and works perfect....Now, I need to retrieve the first column object, so I can display that only column using table.setVisibleColumns, but I´ve being having some trouble....any idea on how to do it?
regards
Hugo
Well, what do you mean by "first-column object"? The ordering of columns depends on you...
Table.getVisibleColumns() should only return the columns that are visible and in the order that they are shown in the table.
However, what exactly are you trying to do? Sounds that you are trying to do things in a hard way and there might have an easier way to do what you want to accomplish.
Hi, thank you very much for your answers...
What I want to do is that from the collection i get using Table.getVisibleColumns(), get the first column and just show that one....It seems simple but for some reson I haven't being able to do it....
any ideas?
regards, and thank you very much!!!!!!!
Hugo
Well, I didn't try this, but from the docs I would say something like this should be sufficient:
table.setVisibleColumns(new Object[] { table.getVisibleColumns()[0] });
Beware of possible NPEs. If this is not the solution you wanted or you did try this and it didn't work, at least I will have to see some code to get a better understanding of your problem.
Tobias Demuth: Well, I didn't try this, but from the docs I would say something like this should be sufficient:
table.setVisibleColumns(new Object[] { table.getVisibleColumns()[0] });
Beware of possible NPEs. If this is not the solution you wanted or you did try this and it didn't work, at least I will have to see some code to get a better understanding of your problem.
It worked perfect, I just wanted to do that, take the first column of an unknown set of properties and hide all the others....
thank you very much Tobias for all your help...
regards,
Hugo