我在新的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)
内部使用正确的字符串列表进行调用。
为什么?有什么我做错了吗?
马尔科
答案 0 :(得分:0)
你是对的...如果在验证期间(在execValidateValue(VALUE rawValue)
中)更改了值,如JavaDoc所建议的那样,该值将正确存储在Scout模型中,但更改不会反映在HTML-中UI。
在Samuel Renold的帮助下,我向团队询问了这个问题:将修复HTML-UI以反映用户界面的变化。请参阅bug 493778。
Demo Widgets应用程序的测试代码。更改DefaultField
中的ListBoxForm
。
@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中重现(此版本已经过期)