Friday, 24 May 2013

44.WHAT IT TAKES TO REUSE A VIEW



While designing any view or any component, we need to design it in such way that it can be reused. The main goal of UI component is reusability. 

For ex : Almost every transaction deals with partners (customers ).  If we want to display those partners on web ui , we need to design a view. Here we won’t design a separate partner view for service contracts, one more view for service orders, one more view for service confirmations and one more for opportunities. 


Instead what we do is we will design one view and reuse it in other transactions. 

There are some steps that we need to do in order to make a view reusable.
First, we should design the view in such way that, it can take data from outside. 

Second, we need to assign this view to a window. 

Third, window should be exposed in the interface view section in the runtime repository. 

Fourth, required context nodes of component controller should be exposed in component interface->interface controller->context section.  

Then we can reuse this view in any other component by creating component usages. 

Let us discuss all points one by one in detail with a practical example.  In the next chapter, we will try to reuse  a view ‘PARTNER’ from component BTPARTNER.

View must be able to take the data from outside. 

Generally data, which come from outside (from another UI component) , fed to the context nodes of component controllers. So one should create binding between the context nodes of component controller and context nodes of view. Here direct binding is not necessary. We just need to make sure that data flow is there from component controller context nodes to the context nodes of view that we want to reuse. 



We can see the BTPARTNERSET context node in the view PARTNER is bound to the context node of component controller. 

Assign the view to WINDOW.
The view should be assigned to a window. Then this window will be exposed in the runtime repository as an Interface view for component.
Go to the runtime repository. 




Partner view is assigned to window. We can a more windows here and each window is having one view assigned to it, making each view a reusable unit.

Window should be exposed in the interface view section in the runtime repository.
Go to the runtime repository -> component interface section. The window partner list is added as an interface view.



Required context nodes of component controller should be exposed in component interface->interface controller->context section.  

Required context node BTPARTNERSET has been exposed in this section. Exposing a context node in this section enables it to be bound by other context nodes of different UI components. We use a special method of component controller WD USAGE INITIALIZE to bind the context nodes of different UI components. 




We all set to reuse this view in our own component. Let us do it in the next chapter.

1 comment: