1

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);
    }
}
4

1 回答 1

2

这是一个已知且已报告的错误,您可以在 Vaadin Trac 错误报告系统 -问题 #17319中找到它。

#17319 - Resolution.MINUTE 的只读日期字段无法正确编辑

当具有 Resolution.MINUTE 的 DateField 被创建为只读并且它的状态在运行时更改时,小时和分钟字段不能被编辑。它们呈现为只读。如果日期字段未创建为只读,但其状态在运行时更改,则一切正常。在版本 7.2.1 之前不存在此错误。我不确定,但它可能与问题 #10262 有关。

于 2015-04-30T10:39:18.530 回答