Hi
I am new to Vaadin so maybe anyone will help me to solve my problem. I have a table with records from bean. On a row click I want to open a pop up window editor form with auto populated data from table record.
EditorWindow popup class
public class EditorWindow extends Window implements Button.ClickListener
{
private Item editItem;
private FormLayout editForm;
private Panel resPanel;
private Button saveButton;
private Button cancelButton;
final FieldGroup binder;
public EditorWindow(Item editItem)
{
this.resPanel = new Panel();
this.resPanel.setSizeUndefined();
this.resPanel.setHeight("400px");
this.resPanel.setHeight("600px");
this.editItem = editItem;
this.editForm = new FormLayout();
this.editForm.setImmediate(true);
this.editForm.setHeight("400px");
this.editForm.setHeight("600px");
this.setHeight("400px");
this.setWidth("600px");
this.setResizable(false);
this.setPositionX((Page.getCurrent().getBrowserWindowWidth()/2)-300);
this.setPositionY((Page.getCurrent().getBrowserWindowHeight()/2)-250);
this.setModal(true);
this.addCloseListener(new CloseListener()
{
@Override
public void windowClose(CloseEvent e)
{
close();
}
}
);
this.binder = new FieldGroup();
this.binder.setBuffered(true);
this.binder.setItemDataSource(editItem);
for (Object propertyId : this.binder.getUnboundPropertyIds())
{
this.editForm.addComponent(this.binder.buildAndBind(propertyId));
}
this.saveButton = new Button("Save",this);
this.cancelButton = new Button("Cancel", this);
this.editForm.addComponent(this.saveButton);
this.editForm.addComponent(this.cancelButton);
this.resPanel.setContent(this.editForm);
this.setContent(this.resPanel);
this.setCaption("Redagavimas");
}
@Override
public void buttonClick(ClickEvent event)
{
if (event.getButton() == this.saveButton)
{
try {
this.binder.commit();
}
catch (CommitException e)
{
e.printStackTrace();
}
}
else if (event.getButton() == this.cancelButton)
{
this.binder.discard();
}
close();
}
}
The problem is that when I call this class from the main UI table onclick event I got the subwindow but it has no components on it. But If I do this directly on the UI I got a list of fully populated fields.
On table item click opens new window and should create and populate fields with data but the subwindow appears empty
public void itemClick(ItemClickEvent event) {
UI.getCurrent().addWindow(new EditorWindow(event.getItem()));
}
That’s how I build and populate fields absed on selected table row
this.binder = new FieldGroup();
this.binder.setBuffered(true);
this.binder.setItemDataSource(editItem);
for (Object propertyId : this.binder.getUnboundPropertyIds())
{
this.editForm.addComponent(this.binder.buildAndBind(propertyId));
}
Any help appreciated