Tree Component

I have the following entities:
Entity: BatchReport
Entity: BatchGroup
Entity: Report

Basically, a BatchReport can contain one or many BatchGroup.
A BatchGroup can contain one or many Reports.
i would like to represent those entities in a tree-like component, very similar to how you represent entities in CUBA studio. A user should be able to click on “New Batch Report” . This will open the screen for the user to create the entity. etc…
Any suggestions on how to go about it? Thanks.

There are two components that are able to display hierarchical structures: Tree and TreeTable.
They require a HierarchicalDatasource, which contains an entity with the link to itself - the “Hierarchy property”.
If you have no such hierarchical entity in your data model, create a synthetic non-persistent entity with the link to itself, and write some code in your screen controller to create instances of this entity and add them to the HierarchicalDatasource.
Please look at the attached project. RootEntity, BranchEntity and LeafEntity are the real entities stored in the database; TreeEntity is a synthetic non-persistent entity to show in the tree. It contains the link to itself (“parent” attribute), and links to real entities. (18.6K)

I tried to use a treetable using some entities. when I run it, i get the following error. Any clue to fix t?
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Problem compiling [
                select e from inteaccgms$PurchaseOrderStatus e
[14, 44] The abstract schema type 'inteaccgms$PurchaseOrderStatus' is unknown.
Exception Description: Problem compiling [
                select e from inteaccgms$PurchaseOrderStatus e
[14, 44] The abstract schema type 'inteaccgms$PurchaseOrderStatus' is unknown.
    at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(
    at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
    at com.sun.proxy.$Proxy133.loadList(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.r

I guess that PurchaseOrderStatus is a non-persistent entity. You cannot query for it. Look at the sample project - the datasource with the non-persistent entity has no query and has refreshMode=“NEVER”.

Ok, have noticed that. What are the ways I can populate the data then?

By creating instance in your code and adding them to the datasource. See

1 Like