Application component based on another application component or addon

Hello,

i use the Reporting-Addon in a project and have written a CustomReport class for it. Now I want to use this class for other projects in form of an own application component.

What is the best practice to create an application component based on another application component or addon in CUBA?

Greetings
Andreas

Hi Andreas,

in general app components are perfectly composable. It is also possible to create an app component that under the hood uses another app component. I do that quite regularly. E.g. in the attachable component it uses multiple other app component (see here: cuba-component-attachable/build.gradle at master · mariodavid/cuba-component-attachable · GitHub)

Back then I did a blog post that explains a little the idea and the different use-cases of app components in general: Decompose the monolith with CUBA application components – Road to CUBA and beyond...

So in your concrete case you can just create an app component: special-reports which under the hood uses reports. In your different usage-scenarios you use the wrapper component special-reports instead of reports directly. In your special-reports component you now put all your logic that should extend / replace the functionality of the report addon.

The scheduled-reports is another example, that does the very same thing: Scheduled Reports – CUBA Platform

I hope this helps as a starting point.

Cheers
Mario

1 Like