Friday, 24 May 2013

45.REUSING A VIEW IN ANOTHER COMPONENT



Read ‘What it takes to reuse a view’ before reading this chapter.
Go to the component ->run time repository and create a component usage.
Click on edit button and right click on component usage and choose the option add component usage. 







In the next dialog box, give name to the component usage and details of interface view and component that we want to reuse. 


 

Choose continue once you enter the details. Now this interface view will act as view in our own component.
Add this view to the overview page. 




Save the runtime repository. Go to the configuration tab of overview page and add the new view to displayed assignment block section. 


 
Now we need to take care of data. In the previous chapter, we know that there is one context node BTPARTNERSET of component controller of component BTPARTNER. So we will create one new same context node at component controller level in our own component.

Go to the component controller and create one context node with base entity BTPartnerSet. 




Give the base entity name and complete the wizard. 



We have created the context node. Then we need to give the data to this context node. There are no of ways doing it.
Let us do it through coding.
As we know, in the event handler (will trigger whey user clicks on hyper link) of result view, we got the BTAdminh entity. We will fetch related BTPARTNER SET from it and feed it to the context node of component controller. 

Do the following changes in the event handler. Save and activate it. 




(This is just part of changed code regarding above scenario. Previous code remains as it as ).  once we got the header entity BTAdminh, we got its related entity BTPARTNERSET using the relation. Once we got the required record we added it to the collection and this collection is fed to the context node of component controller. 

Data feeding to context node is done. There is one more important binding left between the context node of our component controller to the context node of BTPARTNER component controller. As discussed we will use the method WD USAGE INITIALIZE  to do this job. 

Go to the component controller and redefine above mentioned method. 





Once you redefine, and then double click on that method to open it. write the following code in it and activate it. 


Sharing data across context nodes of different components is done.
Test the application. If service contract has any partners, then data will be displayed in the partner assignment block.










5 comments:

  1. No Words to describe ur post Mr.Mannala, U r awesome.....

    ReplyDelete
  2. Hi Mannala,
    Could you tell me the Bol-entity for the view ITEMLIST?

    ReplyDelete
  3. Good Stuff for CRM WebUI Consultants..

    ReplyDelete
  4. hi,
    Very good post.
    i tried the same with gstext / notes view in prdhs/HeaderVS
    i added component registry, added the view in the view area and in the viewset allong with other 4 views..
    i enhanced the component controller and added Text attr and bttext and btadminh and did the binding in wd_usage_initialize

    successfully the view is visible in the header

    but unfortunately not going to edit mode when i click on edit

    i tried to check for reference with other components like BT125H_TASK

    not successful..

    can you guide me

    thanks

    Dhinesh

    ReplyDelete