简体   繁体   中英

Call parent component method in Web Dynpro Java

I'm working with two Web Dynpro Java components (SAP Netweaver Developer Studio 7.0), where the first component is embedding another one and using it in a pop-up window.

The embedded component has a method triggered on a button click, after this method execution I need to call an embedding component method.

Should I use the Web Dynpro Component Interface to call the embedding component method?

Exactly! The steps you should preform are:

  1. Create the wrapper method (with the same signature) in the Interface Controller of your Comp1 (embedding) component, and invoke necessary component controller method there

     wdThis.wdGetComp1Controller.doSmth() 
  2. Add Comp1 to used part of your Comp2 (embedded) component.

  3. Add usage declaration of Interface controller to Comp2 Component Controller in Properties tab.
  4. Now you can be able to access methods of your embedding component (Comp1) like this

     wdThis.wdGetComp1Interface().doSmth(); 

The problem was solved this way:

The embedded component has a button which is going to trigger an Interface Controller event.

  1. On the component we are using as embedded component, we are going to create an Interface Controller event, this event is going to be catched by the parent component method.
  2. Add the embedded component to the parent component on the "DC MetaData > DC Definition > Used DCs" section.
  3. Then add it to the "Used Web Dynpro Components"
  4. At the parent component, open the diagram view of the Web Dynpro Component and add a relationship going from the ComponentController to the Used Web Dynpro Component.
  5. At the parent ComponentController, add an Event Handler in the method's section, select the Web Dynpro component as source of the event and the event that the parent component will be catching in the new method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM