com.vaadin.ui.DateField - 切换只读后时间段不可编辑

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

我有一个带有 DateField 的表单,我希望能够在只读模式和 non-read-only/edit 模式之间切换。

当字段最初是只读的并且我切换到非只读时,日历的时间部分 editable/displayed 不正确。

当字段最初是非只读时,在非只读和只读之间切换是预期的。问题是该字段最初需要是只读的。

我是不是遗漏了什么或者这是一个错误?

我正在使用 vaadin 7.4.4 和 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);
    }
}

这是一个已知和已报告的错误,您可以在 Vaadin Trac 错误报告系统中找到它 - 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.