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.
Viritin TypedSelect rendering problem
Hello,
I have used Viritin's AbstractForm and ComboBox extended from TypedSelect. The problem is that when I opened Abstract Form in a modal popup for modification, value of the ComboBox is set but rendered as it's value is null. Any help will be appreciated. Below are my entities and Viritin components;
package tr.com.logo.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
@Entity(name = "LOGO_STUDENT")
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String surname;
private String studentId;
@ManyToOne
private Classroom classroom;
public Student(String name, String surname, String studentId, Classroom classroom) {
super();
this.name = name;
this.surname = surname;
this.studentId = studentId;
this.classroom = classroom;
}
public Student() {
super();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public Classroom getClassroom() {
return classroom;
}
public void setClassroom(Classroom classroom) {
this.classroom = classroom;
}
}
/* Extension of AbstractForm */
package tr.com.logo.ui.form;
import org.vaadin.viritin.form.AbstractForm;
import org.vaadin.viritin.layouts.MFormLayout;
import com.vaadin.ui.Component;
import com.vaadin.ui.TextField;
import tr.com.logo.domain.Student;
import tr.com.logo.ui.select.ClassroomComboBox;
public class StudentForm extends AbstractForm<Student> {
private TextField name = new TextField("Ad");
private TextField surname = new TextField("Soyad");
private TextField studentId = new TextField("Öğrenci No");
private ClassroomComboBox classroom = new ClassroomComboBox("Sınıf");
public StudentForm() {
}
@Override
protected Component createContent() {
return new MFormLayout(name, surname, studentId, classroom, getToolbar())
.withMargin(true);
}
}
/* Extension of TypedSelect */
public class ClassroomComboBox extends TypedSelect<Classroom> {
@Override
public void attach() {
super.attach();
}
public ClassroomComboBox(String caption) {
super(Classroom.class);
withCaption(caption);
withSelectType(ComboBox.class);
setCaptionGenerator(option -> option.getName());
List<Classroom> classrooms =
VaadinUI.get().getClassroomService().getAllClassrooms();
if(classrooms != null) {
setOptions(classrooms);
}
}
}
Hi,
Did you populate the options into the select? That needs to be done before you bind your entity to the form.
Also note that as you are using JPAEntities, you should probably have some kind of implementation for equals/hashCode. I usually tackle this with an abstract mapped superclass like this.
cheers,
matti