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.
Form with DateField in Window
Hi,
In DefaultFieldFactory of my Form I have a DateField field:
public Field createField(Item item, Object propertyId, Component uiContext) {
final Field f = super.createField(item, propertyId, uiContext);
if (f != null) {
if (f instanceof TextField) {
TextField tf = (TextField) f;
tf.setWidth("100%");
tf.setNullRepresentation("");
}
if (propertyId.equals("tmsStart")) {
((DateField) f).setResolution(DateField.RESOLUTION_MIN);
f.setCaption("start");
}
//other fields ...
}
return f;
}
When I add the Form component to the main window, DateFiled is correctly displayed with the calendar. If I add the Form to a subwindow, the DateField is displayed as a TextField, without calendar.
How can I display a DateField with calendar inside a Window?
Thanks, Francesco
Right now have the same problem, check by debug step by step, all works correct, no mistakes, but in subwindow datefield is empty. Any suggest, what it can be?
It seems I solve my problem, now all works fine.
In this part I collect all data to my class
QQQ qqq = new qqq();
qqq.setValidFrom(validFrom);
getWindow().addWindow(buildSubWindow(qqq));
Here i create new subwindow
private Window buildSubWindow(QQQ qqq) {
Window subwindow = new Window("A subwindow");
subwindow.setHeight("450px");
subwindow.setWidth("350px");
subwindow.addComponent(buildFormEditor(qqq));
subwindow.setModal(true);
return subwindow;
}
here create form
Panel panel = new Panel();
BeanItem personItem = new BeanItem(qqq);
formEditor = new Form();
formEditor.setFormFieldFactory(new FormFieldFactory(){
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
String pid = (String) propertyId;
if(pid.equals("validFrom"))
{
DateField dateField = new DateField("Birth date");
dateField.setDateFormat("dd/MM/yyyy");
return dateField;
}
return null;
}
});
formEditor.setItemDataSource(personItem);
panel.addComponent(formEditor);
Hope this will help you.