Testing 6.3RC1

How is the procedure to do the following:

The term “base project” has been renamed to application component. Any CUBA application can now be used as a component of another application. In order to be used as a component, an application project should contain an app-component.xml descriptor and a special entry in the manifest of the global module JAR. Use Project properties > App component descriptor link in Studio to generate the descriptor and manifest entry for the current project automatically.

I have tried this feature, but got the following exception:


Exception has been thrown by com.haulmont.studio.backend.o.d@69e151c6:
[23:46:33.130] java.io.FileNotFoundException: https://repo.cuba-platform.com/content/groups/work/com/company/testapprc/app-global/0.1-SNAPSHOT 
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1836) 
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) 
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) 
 at com.haulmont.studio.backend.m.c.b(SourceFile:139) 
 at com.haulmont.studio.backend.m.c.a(SourceFile:91) 
 at com.haulmont.studio.backend.m.b.c(SourceFile:97) 
 at com.haulmont.studio.backend.o.d.b(SourceFile:340) 
 at com.haulmont.studio.backend.o.d.a(SourceFile:278) 
 at com.haulmont.studio.ui.n.k.a(SourceFile:89) 
 at com.haulmont.studio.ui.n.k.b(SourceFile:71) 
 at com.haulmont.studio.ui.n.v.commit(SourceFile:203) 
 at com.haulmont.studio.ui.common.b.buttonClick(SourceFile:71) 
 at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source) 
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
 at java.lang.reflect.Method.invoke(Method.java:498) 
 at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508) 
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198) 
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) 
 at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1008) 
 ...
[23:46:33.170] Cannot add application component com.company.testapprc:app-global:0.1-SNAPSHOT

Any ideas?

Hi Kjell,
Thank you for testing the RC.
In your “app component”, before creating App component descriptor, change “Modules prefix” in Project properties > Advanced to something like “mycomp”. Then generate the component descriptor and after that install the component to your local Maven repo: just write “install” in the Search dialog, it will run the Gradle task.
Now the component will be available for including to other projects, you can even see it in the “Registered project” field of the “Custom application component” dialog. We’ll cover all this in the docs shortly.

I’m not sure what you ment with:
The task “Then generate the component descriptor” Is OK.

But this I’m struggeling with:
After that install the component to your local Maven repo: just write “install” in the Search dialog, it will run the Gradle task.

I am not familiar with installing to local Maven.
Do you have the oppertunity to explain to me how to do this?
Step by step.

Okay, the steps:

  • Open the project that will be a component
  • Project properties > Edit > Advanced > Module prefix, change it to “mycomp”
  • Project properties > App component descriptor > OK
  • Invoke the Search dialog (either click the looking glass icon in toolbar or press Alt+/). Type “install”, you’ll see “install - Gradle task”. Press Return - it will be executed.
  • Open the project that will use the component.
  • Project properties > Edit > Custom components, Select the component project in the “Registered project” list. Click OK.
  • Save Project properties.
    Done. Now you can use functionality of your component in the current project. For example, if the component contains the Customer entity, you can create the Order entity in your project and make a relation to Customer.

As for local Maven repo - it’s just a folder in your home directory: ~/.m2. You don’t have to install Maven on your machine, the Gradle build system has everything needed to work with Maven repositories.

Ok. Now I have tried to follow your steps. I Succeded in building the first application.

  • Open the project that will be a component

  • Project properties > Edit > Advanced > Module prefix, change it to “mycomp”

  • Project properties > App component descriptor > OK

  • Invoke the Search dialog (either click the looking glass icon in toolbar or press Alt+/). Type “install”, you’ll see “install - Gradle task”. Press Return - it will be executed.

  • Open the project that will use the component.

  • Project properties > Edit > Custom components, Select the component project in the “Registered project” list. Click OK.

  • Save Project properties.

When I build the second application that uses the component I got the following Exception from Cradle build:

Total time: 0.9 secs [13:36:40.422] Task 'updateDb, setupTomcat, deploy, start' failed
java.io.FileNotFoundException: JAR entry META-INF/MANIFEST.MF not found in C:\Users\kjell\.m2\repository\com\company\testapprc\mycomp-global\0.1-SNAPSHOT\mycomp-global-0.1-SNAPSHOT.jar

I have tried to include the component several times but got the same exception.

I tried to create a new Project and include the Component.
Here I succeded in getting the component but, I cannot access the Customer Entity from Ex: Order Entity as Association in Cuba-studio nor in the IDEA. It looks like the component is installed but the objects is not visible in Studio. The jar is not loaded in the IDEA.

This problem is usually caused by locking the JAR file by a running process on Windows. Try to close Studio and IDE, execute “gradle --stop” in command line to kill the Gradle daemon, then start Studio again and in the component project repeat the “install” step.

That’s strange. Can you attach build.gradle of the application here?

Hi Konstantin.
I have attached both projects.
TestAppRC1 Comp Proj contains the Component to be included into main project.
Contains Entity Customer and related screens

TestCompApp MainProj contains the main Project that will import the Component.
Contains only one entity Order.

If i try to add an association to Customer component the Entity Customer is not presentet in the list of Enities.

TestAppRC1 Comp Proj.zip (449.0K)

TestCompApp MainProj.zip (297.9K)

Hi Kjell,
The build.gradle of your MainApp project does not contain the dependency on the component in the buildscript/dependencies section. So please try to repeat these steps:

  • Open the project that will use the component.
  • Project properties > Edit > Custom components, Select the component project in the “Registered project” list. Click OK.
  • Save Project properties.
    After that, ensure there is the following line in the build.gradle of the main app:

buildscript {
...
    dependencies {
...
        classpath "com.company.testapprc:mycomp-global:0.1-SNAPSHOT"
    }

I am not sure why it didn’t work the first time.
What I this now was I remove the old projects and started from scratch.
Created a project called CustomerApp and run the prosedure for creating app component.
Second i create a new project and called the project MainApp and prefixed it with mainapp.
Then I added the newly created CustomerApp as component and tried to add Customer Enity into Order Entity.
Now it worked as expected. I also got a new menu item “customer.browse” with screens in the new project.

What I miss is the abillity move the menu item from component into a new menu group if I want to change the arrangment of menus and items in the new project. I can move the menu items from the host project into the menu group of component, but not the other way. from component to host project.
It would be easier to manage the menu arrangement in the new project if we have the abillity to arrange the menu items as we want without Cuba blocking the abillity to move menus and items.

Good to hear that it works now.

> I can move the menu items from the host project into the menu group of component, but not the other way. from component to host project.
Unfortubately, this is impossible - you cannot modify the inherited menu items, you can only place your items between them. But you can also switch the menu designer into “Single” mode - in this case the menu will contain only items from your project, and you will be able to add items for screens from the components in arbitrary structure.

How will it work if I later wants to modify the Component project.
Is it possible to just copy the jars or do I have to include the project as component once again?

After modification of the component project, repeat this step:

  • Invoke the Search dialog (either click the looking glass icon in toolbar or press Alt+/). Type “install”, you’ll see “install - Gradle task”. Press Return - it will be executed.

Then just open the host project - it will see the changes.

I send the source code for the projects to in this comment.
Test with the following:

  • Import TestApp to MainApp. By running install in TestApp. Then add Component to MainProject.
  • Make some modifications in the TestApp and then run install again in the TestApp.
  • Try to Open the MainApp. You will get an exception as presented in the previous comment.
  • What is causing the exceptions?

MainApp.zip (218.9K)

TestApp.zip (87.5K)

Probably the same as I explained in my previous comment: https://www.cuba-platform.com/discuss/t/testing-6-3rc1_1#comment-2190
If you have IDE running, close it completely before doing “install” of the component.

We’ve just published a step-by-step guide to working with app components: https://doc.cuba-platform.com/manual-6.3/app_components_sample.html

It’s valid for RC2+.

How would it be if I want to create a sales order view an add it to the customer editor.
Let’s say that I want to see all sales orders for this particular customer.

I have added the customer component to sales project
Can I add the sales component to the customer project?
.

That’s a great question.

You definitely cannot add sales as a component to the customers project - circular dependencies are not allowed. But you can extend the functionality of a component in your application.

For example, to add a list of orders to the customer editor screen, you should:

  • Open the sales project.

  • Click New screen*, select *Extend an existing screen and select customer-edit.xml as a parent screen.

  • Add a new collection datasource for Order and write a query for it: select e from sales$Order e where e.customer.id = :ds$customerDs.

  • Add a table and link it to the datasource.

You can also define new views for Customer when you create datasources for it (notice the plus button in the View field). They will not be visible in the Entities tree (because it doesn’t display entities from components), but you can see and edit it directly in the views.xml file of the global module in the sales project.