App component database and screen extensions

Hello, I’m facing some misunderstanding in working with app components in 7.1. I’ve read some threads in forum and app component section of documentations, but none of them answer my questions. Let’s say i have projects Parent and Child. Child is an installed app component of Parent. I have two questions about them:

  1. Child has it’s own database and entities. I created DD scripts, created an app-descriptor, uploaded archives into my local nexus, added a dependency to Parent. Do i need any more settings to create them (DB scripts) in Parent? I tried re-creating DB for Parent, but Child’s entities are still not there… can’t remember it to be a big deal in 6.9. What am i doing wrong?

  2. If a have a Main Screen extension in Child, how do i make Parent to use it? do i need to extend Child’s screen? Can i make more than one Main screen extensions in Children, and how to apply them to Parent?

Best regards, Ivan

Hello @ocrio.box

  1. App Component DB Scripts

In fact you do not have to do anything to apply application component DB scripts to the parent database.

I suggest you to log createDb task execution and check whether app component scripts are found or not:

gradlew createDb -i > createdb.log

  1. App Component Main Screen Usage

In CUBA 7.1 you can use the cuba.web.mainScreenId application property to specify main screen id to use.

For further information please read our documentation: Main Screen.

Regards,
Daniil

Thanks for your answer, Daniil!
1 somehow it worked, thank you, but still, where can i get more info about this process? What should i do if scripts are not found? or if they are found, but entities are still not there?
2 do i need to (and how do i) use package names in the cuba.web.mainScreenId option, cos all the extensions of main are called quite the same names. And when i use the name from the added component - it’s not found, and i cant get into application, it throws an exception - screen not defined?

  1. As an option DB scriprts archive could be not installed or compiled correctly. In general, checking task logs is the simpliest way to track what’s happening.

  2. No, just use screen id from @UiController annotation (or from screens.xml entry corresponding attribute)

1 thanks, i think i got the idea
2 if i don’t add Child’s main screen extension to web-screens.xml of a Parent, i get not defined. if i do, i get unable to create screen with type FRAGMENT. Child has an empty web-screens.xml, mainscreen extension is marked with @UIController. maybe i should create a sample project to show this behavior?

I’ve prepared two small projects to demonstrate how app component main screen can be used in “master” application. Please follow these instructions:

  1. Execute gradlew assemble install for the appcmp project
  2. Import the appcmp-parent project and run it

Extended main screen from the application component is used in the parent project in the web-app.properties file:

cuba.web.mainScreenId = extMainScreen

appcmp.zip (68.2 KB)

appcmp-parent.zip (67.9 KB)

maybe the problem is that my appcmp is not installed locally, but is in the local network nexus. maybe it’s cos my appcmp has another namespace… but your example works, and the very same code in my project does not… Screen 'extMainScreen' is not defined. i add screenshots of my parent and my child that show proper component installation and my problem…

_child

_parent

Could you clarify whether app component main screen is opened when app component is running independently?

yes, it works as expected, it contains and extra component and some extra service invocations. Created a new clean project as a Parent. added a dependency for Child through CUBA - Marketplace menu, added mainScreenId property. mailing_main is still not defined.

I’ll try to investigate the problem and give you an answer as soon as possible.

1 Like

Hello, is there any more information i can provide, to help the investigation?

Hi,

I suggest you to debug a method that registers screens to check that required main screen is successfully found: WindowConfig#registerScreen(UiControllerDefinition, WindowInfo).

It seems that there is some problem with screen registration.

Sorry for the long time answer. As i enter the WindowConfig#registerScreen(UiControllerDefinition, WindowInfo) for the fourth time (first three screens were inputDialog, login and main, i have the following arguments for this method:
definition = UiControllerDefinition{id='notFoundScreen', ...}
windowInfo = WindowInfo{id='notFoundScreen', ...}
where should i make further research?

Hello @ocrio.box

Could you clarify whether extended main screen defined in app component is shown if you launch the app component itself?

Could you also check that the screen package is included into screens base packages:

image

Regards,
Daniil

Thanks for keeping in touch with my problem, yes, screen extension works fine in child. web-screen.xml of both parent and child apps contain information about their own web package. I also noticed, that i can’t @Inject child's service on my parent's screen, but it’s seen in project’s scope… maybe there is a problem adding a dependency in build.gradle / spring / anywhere else?

Could you check whether app component web-spring.xml is exposed in app-component.xml descriptor?

image

1 Like

Thank you, it worked with the screen, but still i have a couple of questions about it:

  • why this property wasn’t included in app-component descriptor automatically?
  • why can’t i inject a service, despite having property spring.xml in core section of descriptor?
  • where to look for a proper full app component descriptor, as a checklist for further modules?

why this property wasn’t included in app-component descriptor automatically?

Probably it’s a but of CUBA Studio. We’ll check the case.

why can’t i inject a service, despite having property spring.xml in core section of descriptor?

It depends on the case. Could you share some details?

where to look for a proper full app component descriptor, as a checklist for further modules?

Unfortunately there is no any example to compare, because some properties are not always present in a descriptor.

Thanks for the answer, maybe you should think about more detalized description of app component descriptor in docs or cookbook (what properties affect which functionality etc)

It depends on the case. Could you share some details?

So the case is that i still can’t @Inject the child's service into parent. Screen extension works fine, so i can guess, that the problem is in the app component descriptor, but spring.xml property exists in core section of it. i re-created app component descriptor after adding web-spring property manually, studio added 5 more rows and now it works fine. somehow…

maybe you should think about more detalized description of app component descriptor in docs or cookbook

In most cases everything should be handled by CUBA Studio, so you should not change it manually. All other cases cannot be described in generic way.

1 Like