gpt4 book ai didi

java - GWT 编辑器使用 IsEditor> 填充 Long 字段

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:49:53 27 4
gpt4 key购买 nike

我刚刚掌握了使用 Editor framework 的窍门,并且正在移植我所有的表单来使用它。我在处理 Event 表单时遇到了一些问题。我有 5 个不同的 time fields - 对于每个字段,我都使用 DateBox 来允许用户选择时间。

在我的旧Activity 中,我将这些字段的值转换为Long 时间,填充我的代理对象 并保存它。

我想使用 Editor framework 做同样的事情。无论如何我可以使用带有 DateBoxEditor 来填充我的域对象中的 Long 字段。我确信一定有办法做到这一点,我只是无法弄清楚。

如果不是这种情况,我现在不能这样做,有没有人知道如何做到这一点的好的解决方案?

最佳答案

你必须包装 DateBoxEditor<Long> .像这样的东西:

@Editor.Ignore
@UiField
DateBox dateField;

LeafValueEditor<Long> longField = new LeafValueEditor<Long>() {
@Override
public Long getValue() {
Date date = dateField.getValue();
return date == null ? null : date.getTime();
}
@Override
public void setValue(Long value) {
Date date = value == null ? null : new Date(value.longValue());
dateField.setValue(date);
}
}

关于java - GWT 编辑器使用 IsEditor<LeafValueEditor<Date>> 填充 Long 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8815118/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com