tstefanov

Blog of Tzanko Stefanov

Embedding Views From Other Components


Some might say that this is quite trivial, but the other day I witnessed a somewhat tricky to spot error related to reusing views. A colleagues of mine was integrating a UI component into CRM quotation page. My colleague had created a reusable custom UI component with an assignment block (view). At first all appeared to be going smoothly.  My colleague was able to show the custom view on the quotation OVP. But upon further analysis, it became apparent that something was wrong:

  • The custom window controller was never created – hence important logic in method do_init_context was never executed
  • When trying to access the custom component controller from the custom views,  ME->COMP_CONTROLLER did not refer to the component controller of the custom UI component but to the component controller of the embedding component (component BT115QH_SLSQ) .

Our assumption was that something went wrong when creating the component usage to the custom UI Component but we did not find anything suspicious there. Then I looked carefully at what was added to the quotation OVP in the runtime repository. The custom view was there but it’s name appeared a bit strange. It did not contain the name of the component usage.

View added without a component usage

View added without a component usage

It became clear that the embedded view had been added directly to the OVP instead of using the created component usage. This of course explained why one would not get the component and window controllers of the custom UI component. They were simply never instantiated. The view was instantiated as an independent UI element.

How one shall not add views

How one shall not add views

I removed the view and added it through the existing component usage.

How to embed views

How to embed views

Next we cleaned the configuration and added the new view to the OVP layout. As expected the controllers of the custom UI component got instantiated and their functionality became available to our embedded view.

Proper Embedding

Proper Embedding

Although by all means the above information is not revolutionary it might help you avoid the same mistake. However, it also shows that you can reuse standalone/independent views without a component usage.

Leave a comment