【问题标题】:Eclipse Scout Neon ListBox: execValidateValue(..) not workingEclipse Scout Neon ListBox:execValidateValue(..) 不起作用
【发布时间】:2016-05-17 17:30:50
【问题描述】:

我在新的 Neon Scout 中有列表框,我想验证设置的值。

我已经实现了execValidateValue 方法:

  @Override
  protected Set<String> execValidateValue(final Set<String> rawValue) {

    if (rawValue.contains(CONSTANT.UNKNOWN)) {
      final Set<String> unknownSet = new HashSet<String>();
      unknownSet.add(CONSTANT.UNKNOWN);
      return super.execValidateValue(unknownSet);
    }

    return super.execValidateValue(rawValue);
  }

但它没有接缝有任何效果。在调试时,我看到在 setValue(VALUE rawValue) 内部方法 updateDisplayText(validatedValue) 是用正确的字符串列表调用的。

这是为什么呢?是不是我做错了什么?

马尔科

【问题讨论】:

    标签: validation listbox eclipse-scout


    【解决方案1】:

    你是对的...如果在验证期间(execValidateValue(VALUE rawValue))按照 JavaDoc 的建议更改了值,则该值会正确存储在 Scout 模型中,但更改不会反映在 HTML-UI 中。

    在 Samuel Renold 的帮助下,我向团队询问了这个问题:HTML-UI 将被修复以反映 UI 中的变化。见bug 493778


    演示小部件应用程序的测试代码。更改ListBoxForm中的DefaultField

    @Order(20)
    public class DefaultField extends AbstractListBox<Color> {
    
      @Override
      protected Class<? extends ICodeType<?, Color>> getConfiguredCodeType() {
        return ColorsCodeType.class;
      }
    
      @Override
      protected Set<Color> execValidateValue(Set<Color> rawValue) {
        System.out.println(">> execValidateValue");
        printColors(rawValue);
        if (rawValue != null && rawValue.contains(Color.RED)) {
          return super.execValidateValue(Collections.singleton(Color.RED));
        }
        return super.execValidateValue(rawValue);
      }
    
      private void printColors(Set<Color> rawValue) {
        if (rawValue != null) {
          for (Color color : rawValue) {
            System.out.print(color + ", ");
          }
          System.out.println("");
        }
        else {
          System.out.println("null");
        }
      }
    
      @Override
      protected void execChangedValue() {
        System.out.println(">> execValidateValue");
        printColors(getValue());
    
      }
    
      @Override
      protected int getConfiguredGridH() {
        return 5;
      }
    
      @Override
      protected String getConfiguredLabel() {
        return TEXTS.get("Default");
      }
    }
    

    错误行为也可以在 Scout 4 中重现(此版本已停产)

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-15
    • 2016-06-29
    • 2016-07-24
    • 2016-04-24
    • 2016-09-22
    • 2016-07-08
    • 2016-06-29
    • 2016-07-16
    相关资源
    最近更新 更多