Vaadin CRUD用户界面(用于相关实体)

时间:2018-11-11 00:04:56

标签: java user-interface view orm vaadin

如何显示相关实体的UI部分?

如果我对商品实体有这样的网格

    GridCrud<T> crud = new GridCrud<T>(tClass);
    crud.getCrudFormFactory().setUseBeanValidation(true);
    crud.setFindAllOperation(() -> (Collection<T>)repository.findAll());
    crud.setAddOperation(repository::save);
    crud.setUpdateOperation(repository::save);
    crud.setDeleteOperation(repository::delete);

产品是下一个

public class Product {//...
@ManyToMany
@JoinTable(name = "optionToProduct",
        joinColumns = {@JoinColumn(name = "optionId")},
        inverseJoinColumns = {@JoinColumn(name = "productId")})
private Set<Option> options = new HashSet<>();
}

如何在编辑过程中显示每个产品的选项列表?

Vaadin

    <dependencyManagement>
<dependencies>
  <dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-bom</artifactId>
    <version>8.2.0</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
 </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-spring-boot-starter</artifactId>
        <version>2.0.1</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.crudui</groupId>
        <artifactId>crudui</artifactId>
        <version>2.3.0</version>
    </dependency>

1 个答案:

答案 0 :(得分:0)

GridCrud不是默认情况下Vaadin中可用的类,因此您正在使用团队的附加组件或自定义代码。您可以检查它的来源吗?这样可以使其他人更轻松地为您提供帮助。

我不确定grid.getCrudFormFactory()会返回什么,但这听起来像是配置它们的正确位置。就是formFactory.addField(field,component);或类似的东西。