You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vaadin 24.0 TextField错误消息不显示问题咨询

TextField错误消息显示异常

以下是我的代码片段:

public MainView() {
    var tf = new TextField();
    tf.setWidth("30em");
    tf.setClearButtonVisible(true);
    tf.setRequired(true);
    tf.addValueChangeListener(event -> {
        if (event.getValue() == null || !event.getValue().contains("a")) {
            tf.setInvalid(true);
            tf.setErrorMessage("Error: input should be a text containing letter 'a'");
        } else {
            tf.setInvalid(false);
            tf.setErrorMessage(null);
        }
    });
}

设置的错误消息无法显示,但点击清除按钮时消息会正常展示;再次输入无效内容后,错误消息又不再显示。

输入无效文本后的状态:
输入无效文本后的界面

点击清除按钮后的状态:
点击清除按钮后的界面

内容的提问来源于stack exchange,提问作者rmuller

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 22:24:57