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, 2 weeks ago
addContainerProperty and Select.class
I have a problem with addContainerProperty, getContainerProperty and Select class.
Starting from http://vaadin.com/tutorial, SimpleAddressBook.java, i just added those lines in createDummyData method
private static IndexedContainer createDummyData() {
//... unaltered variables
for (String p : fields) {
if(p.equals("Company")){
ic.addContainerProperty(p, Select.class, null); // added by me
}
ic.addContainerProperty(p, String.class, "");
}
for (int i = 0; i < 1000; i++) {
Object id = ic.addItem();
ic.getContainerProperty(id, "First Name").setValue(fnames[(int) (fnames.length * Math.random())]);
ic.getContainerProperty(id, "Last Name").setValue(lnames[(int) (lnames.length * Math.random())]);
Select s = new Select(); // added by me
s.addItem("one");
s.addItem("two");
ic.getContainerProperty(id, "Company").setValue(s);
}
return ic;
When accesing any rows, editor in right part of window doesn't render Select values, while left Table control does.
I also added those lines to initLayout method:
private void initLayout() {
// unaltered lines
contactEditor.setImmediate(true);
contactEditor.setFormFieldFactory(new FormFieldFactory() { // added by me
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
String p= (String) propertyId;
if(p.equals("Company")){
return new Select(p);
}else{
return new TextField(p);
}
}
});
bottomLeftCorner.setWidth("100%");
// unaltered lines
}
Screen capture:
Thanks in advance,
Last updated on Apr, 20th 2010
You cannot reply to this thread.