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: https://github.com/mariodavid/cuba-component-attachable/blob/master/build.gradle#L102-L108)

Back then I did a blog post that explains a little the idea and the different use-cases of app components in general: https://www.road-to-cuba-and-beyond.com/decompose-the-monolith/

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: https://www.cuba-platform.com/marketplace/scheduled-reports/

I hope this helps as a starting point.

Cheers
Mario

1 Like