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.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
ComboBox and BeanContainer
Hello,
in our Vaadin application we use a lot comboboxes.
Usually only with two values (id and value).
Do I now write for each Combo a BeanContainer with its own class?
Or is there a simpler way to put two values from a database into a ComboBox?
Sample:
BeanContainer<String, Vertrag> [b]container [/b]= new BeanContainer<String, Vertrag>(Vertrag.class);
container.setBeanIdProperty("id");
... select form Database:
while(){
//put Value into Bean
[b]container[/b].addBean(new Vertrag(String xy, String id));
}
//put BeanContainer into ComboBox...
cbxvertrag.setContainerDataSource(container);
cbxvertrag.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
cbxvertrag.setItemCaptionPropertyId("name");
Many thanks in advance
Last updated on Jul, 9th 2012
ComboBox cb = new ComboBox();
cb.addItem("FED");
cb.setItemCaption("FED", "Federation");
cb.addItem("INV");
cb.setItemCaption("INV", "Innovation");
main.addComponent(cb);
and
// to show the value:
cb.setImmediate(true); // update the label immediatly
Label selected = new Label(cb);
main.addComponent(selected);
Last updated on
You cannot reply to this thread.