Dynamically / Programatically adding UI component to an existing screen


I would like to add components (tabs and form fields) to an existing screen, based on some JavaBean rules and contents.
Is there Java code example that add a new UI component to a container of a CUBA screen created using the CUBA designer ?
Same question about a Java code example explaining how to bind a component to data container ?

Thank you !

Hi @richard.thibault,

You just need to inject the container in the controller and then add child components into this container. To create the components, take a look at UiComponents.

Take a look at this answer from @durygin in another topic.



If you want to get the hardcore example of programmatic building CUBA screens - you should take a look into Administration -> Entity Inspector.
It is a screen that builds entity browser or entity editor programmatically by looking at entities metadata.

Source code: com.haulmont.cuba.gui.app.core.entityinspector.EntityInspectorBrowse and com.haulmont.cuba.gui.app.core.entityinspector.EntityInspectorEditor.

Unfortunate thing is - these screens use old obsolete GUI APIs (AbstractWindow and datasources instead of data containers).
But still those screens are the best example of walking through CUBA metadata annotations, discovering associations, compositions, building views to load data, creating tabsheet tabs etc.

Thank you to both of you !