I am not able to put a NativeSelect into a Grid. The result is always: Screenshot - NativeSelect in Grid.JPG
Can someone please help me?
method init
[code]
package de.thalia;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.*;
import java.util.Arrays;
import java.util.List;
@Title(“My UI”)
@Theme(“mytheme”)
public class MyUI extends UI {
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
NativeSelect nativeSelect = new NativeSelect<>();
nativeSelect.setItems("Option1", "Option2");
List<Person> people = Arrays.asList(
new Person("Marc", "Born", nativeSelect),
new Person("Andrew", "Moritz", nativeSelect),
new Person("Michael", "Toast", nativeSelect));
Grid<Person> grid = new Grid<>();
grid.setItems(people);
grid.addColumn(Person::getFirstName).setCaption("First Name");
grid.addColumn(Person::getSecondName).setCaption("Second Name");
grid.addColumn(Person::getHobbies).setCaption("Hobbies");;
layout.addComponent(grid);
setContent(layout);
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}
[/code]
class person
package de.thalia;
import com.vaadin.ui.NativeSelect;
public class Person {
String firstName;
String secondName;
NativeSelect nativeSelect;
public Person(String firstName, String secondName, NativeSelect nativeSelect) {
this.firstName = firstName;
this.secondName = secondName;
this.nativeSelect = nativeSelect;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getSecondName() {
return secondName;
}
public void setSecondName(String secondName) {
this.secondName = secondName;
}
public NativeSelect getHobbies() {
return nativeSelect;
}
public void setHobbies(NativeSelect nativeSelect) {
this.nativeSelect = nativeSelect;
}
}