javavaadinvaadin7vaadin4spring

com.vaadin.ui.DateField - time section not editable after toggling read-only


I have a form with a DateField and I want to be able to toggle between read-only mode and non-read-only/edit mode.

When the field is initially read-only and I switch to non-read-only then the time section of the calendar isn't editable/displayed correctly.

When the field is initially non-read-only toggling between non-read-only and read-only works es expected. The problem is that the field initially needs to be read-only.

Am I missing something or is this a bug?

I'm using vaadin 7.4.4 with vaadin-spring-boot-starter-1.0.0.beta2.

@SpringUI()
@Theme("valo")
public class TestUI extends UI {

    @Override
    protected void init(VaadinRequest request) {
        DateField dateField = new DateField();
        dateField.setResolution(Resolution.MINUTE);
        dateField.setValue(new Date());
        dateField.setReadOnly(true);

        Button button = new Button("toggle read-only");
        button.addClickListener(event ->   dateField.setReadOnly(!dateField.isReadOnly()));

        VerticalLayout pageLayout = new VerticalLayout(dateField, button);
        pageLayout.setSpacing(true);
        pageLayout.setMargin(true);

        setContent(pageLayout);
    }
}

Solution

  • It is a known and reported bug, you can find it in Vaadin Trac Bug Reporting system - Issue #17319.

    #17319 - Readonly date field with Resolution.MINUTE can not be made editable properly

    When a DateField with Resolution.MINUTE is created as read only and it's state is changed at runtime, hour and minute fields can not be edited. They are rendered as read only. If date field is not created as read only, but it's state is changed at runtime, everything is ok. This bug doesn't exist before version 7.2.1. I'm not sure but it might be related with issue #10262.