【问题标题】:GWT Editor use IsEditor<LeafValueEditor<Date>> to populate Long fieldGWT 编辑器使用 IsEditor<LeafValueEditor<Date>> 填充长字段
【发布时间】:2012-01-11 06:33:44
【问题描述】:

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

在我的旧Activity 中,我将这些字段的值转换为Long 次,填充我的proxy object 并保留它。

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

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

【问题讨论】:

    标签: java gwt gwt-editors


    【解决方案1】:

    您必须将DateBox 包装在Editor&lt;Long&gt; 中。比如:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-03
      • 2012-06-16
      • 1970-01-01
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多