【问题标题】:Vaadin flow: format number when focus leavesVaadin flow:焦点离开时格式化数字
【发布时间】:2023-02-17 04:33:16
【问题描述】:

我们在我们的应用程序中使用 TextField 作为数字输入字段。因为 TextField 值是一个字符串,所以我们向 TextField 添加了各种转换器。例如,

TextField textFieldNetWeight = new TextField()
BindingBuilder<?, ?> bb = binder.forField(textFieldNetWeight );
((BindingBuilder<?, String>)bb).withConverter(new StringToBigDecimalConverter("Failed to convert"));

setBean 和 getBean 用于绑定。当用户输入净重,焦点离开该字段时,该字段在 V8 中显示格式化数字(千位分隔数字),但在 V14 中不显示。我们知道转换器是正确的,因为当数据被保存并再次显示时,数据被格式化了。

当焦点离开该字段时,我该怎么做才能让它显示格式化的数字?

由于种种原因,这里不能使用writeBean和readBean。

提前致谢。

【问题讨论】:

    标签: migration vaadin vaadin-flow


    【解决方案1】:

    您所指的功能仅在 8.12+ 和 19+ 中默认处于活动状态。

    您需要在 14.x 中的绑定上使用 setConvertBackToPresentation(true) 才能启用此行为。

    【讨论】:

      猜你喜欢
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-19
      • 2021-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多