Hello!
Sorry for my english!
I have a problem! I use the automatic generation of the form.
I set DataSource like type DocType for the form. DocType includes object type field DocGroup
public class DocType {
private int id;
private String name;
private String code;
private String note;
private DocGroup docGroup;
//Getters and Setters...
This is DocGroup type.
public class DocGroup {
private int id;
private String name;
//Getters and Setters...
}
I’m using FormFieldFactory for generating Form’s fields. In the method createField I’m create ComboBox component.
class MyFieldFactory implements FormFieldFactory
{
private ComboBox select;
public Field createField(Item item, Object propertyId,
Component uiContext) {
if (propertyId.equals("code")) {
return new TextField("Code");
} else if (propertyId.equals("name")) {
return new TextField("Name");
} else if (propertyId.equals("docGroup")) {
select = new ComboBox("Doc group");
select.addContainerProperty("docGroup", DocGroup.class, null);
select.setItemCaptionPropertyId("name");
JPAContainer<DocGroup> container = JPAContainerFactory.make(DocGroup.class, "Myunut");
select.setContainerDataSource(container);
select.setNullSelectionAllowed(false);
select.setImmediate(true);
// select.addListener(this);
return select;
} else if (propertyId.equals("note")) {
return new TextField("Note");
}
return null;
}
}
When I’m change DocGroup field in form and commit the form, I’m received in beanItem null in all fields object DocGroup.
BeanItem<DocType> beanItem = (BeanItem<DocType>) form.getItemDataSource();
How i can get changed DocGroup object or id of selected DocGroup item? Help me please!