Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Select 组合框中的项目选择不起作用_Select_Combobox_Vaadin - Fatal编程技术网

Select 组合框中的项目选择不起作用

Select 组合框中的项目选择不起作用,select,combobox,vaadin,Select,Combobox,Vaadin,我在选择vaadin组合框中的值时遇到问题,我用从EJB3层获得的对象填充了该组合框。我已经覆盖了类的toString,这样combobox就可以显示所需的属性,而不是object的序列值 试用 cb.setValue(object) 及 但它不起作用 有什么想法吗 从数据库获取数据的代码: @SuppressWarnings("unchecked") public List<Kontakt> findAll() { log.debug("getting all Kont

我在选择vaadin组合框中的值时遇到问题,我用从EJB3层获得的对象填充了该组合框。我已经覆盖了类的toString,这样combobox就可以显示所需的属性,而不是object的序列值

试用

cb.setValue(object) 

但它不起作用

有什么想法吗

从数据库获取数据的代码:

@SuppressWarnings("unchecked")
public List<Kontakt> findAll() {
    log.debug("getting all Kontakts");
    try {
        List<Kontakt> instance = entityManager.createNamedQuery("Kontakt.findAll").getResultList();
        log.debug("get successful");
            return instance;
    } catch (RuntimeException re) {
        log.error("get failed", re);
        throw re;
    }
}

equals和hashCode是如何在对象上实现的?是的,正如Henri提到的,检查hashCode和equals是否实现了。我相信有更好的方法来显示值,而不是使用ToString。如何填充组合框?你能展示你的代码让我们看到ClassCheckHashCode和equals实现吗。那你就对了。在实体类中实现hashCode和equals之后,一切都正常了。谢谢
@SuppressWarnings("unchecked")
public List<Kontakt> findAll() {
    log.debug("getting all Kontakts");
    try {
        List<Kontakt> instance = entityManager.createNamedQuery("Kontakt.findAll").getResultList();
        log.debug("get successful");
            return instance;
    } catch (RuntimeException re) {
        log.error("get failed", re);
        throw re;
    }
}
cbUstanova = new ComboBox("Ustanova");
cbUstanova.addItems(ustanovaEJB.findAll());
cbUstanova.setRequired(true);