Hi guys,
I need a little help on how to get all the data inside a table without using multi-select method.
Hi guys,
I need a little help on how to get all the data inside a table without using multi-select method.
Hello,
If you want what is selected you can use the getValue() from the Table. It will return a Set with all selected lines. If you want really all data you can get its container with the getContainerDataSource() and use the getItemIds() if it is a BeanItemContainer.
Regards
Bruno
Thank you for a quick response…
I have actually two tables. table1 holds the data from my datasource(db), each time I select a row, it passes the value to table2 (I already have done this successfully). What I need is to get all the data from table2 and save it on my database when I press a button.
You could probably use the JPAContainer on table2 and that would ease your job. If not you have to take the data through the Table’s container as a I told you previously.
Regards
Bruno
I’ll try your suggestion… Thank you very much. -_-
Hi bruno, your suggestion works like a charm… Thanks
Collection i = table2.getContainerDataSource().getItemIds();
for(int x = 1; x <= i.size(); x++){
System.out.println(table2.getItem(x));
}
What kind of database? If you’re using SQL, take a look at
https://vaadin.com/book/-/page/sqlcontainer.html
.
this is correct only if the IDs are incrementals like the counter ‘x’
you can considre this snippet regarless how the IDs are constructed (incremental, decremental,or randomly)
Collection i = table.getContainerDataSource().getItemIds();
Iterator<?> walker=i.iterator();
for(int x = 1; x <= i.size(); x++)
System.out.println(table.getItem(walker.next()));