如何使用Vaadin上的withConverter方法防止Binder中的“null”文本

时间:2017-09-28 15:20:27

标签: java vaadin vaadin8

如何在使用Binder "null"方法时阻止显示文字 withConverter

    TextField id = new TextField("Id");
    TextField name = new TextField("Name");

        Binder<Customer> b = new Binder<>();

        b.forField(id)
                .withConverter(Integer::valueOf, String::valueOf, "Invalid")
                .bind(Customer::getId, Customer::setId);
        b.forField(name)
                .bind(Customer::getName, Customer::setName);
        b.readBean(customer);

结果是:

enter image description here

  

如何在不丢失验证类型的情况下进行转换?

1 个答案:

答案 0 :(得分:1)

最后,我找到了使用vaadin API的解决方案,感谢您的帮助@Shirkam

set.seed(1234)
df <- data.frame(v1 = sample(1:50, 10, TRUE), v2 = sample(1:4, 10, TRUE))

cond1 <- df$v1 %in% c(2,4:7,9,12:13,16,18:23,26,33,35,39,41:43,45:46) & 
    df$v2 %in% c(1,2) # first condition of the rule     
cond2 <- df$v1 %in% c(1,3,8,10:11,14:15,17,24:25,27:32,34,36:38,40,44,47:50) & 
    df$v2 %in% c(3,4) # second condition of the rule

df$v3 <-  cond1 | cond2 

#if you really want a factor

df$v3 <- as.factor(cond1 | cond2)