cancel
Showing results for 
Search instead for 
Did you mean: 

Subscribe events from another component

Former Member
0 Kudos

Hi all,

I want my component MovimientosAlmacen_com to catch the "Importar" event from other component FileInterface_comp, so I put the event in the interface controller of FileInterface_comp, then in the wdDoInit() method of my component controller I put this code:

IWDEventId eventId = wdThis.wdGetFileInterfaceInterface().WD_EVENT_IMPORTAR;
IWDEventHandlerId eventHandlerId = wdThis.WD_EVENTHANDLER_ON_IMPORTAR;
wdComponentAPI.addEventHandler(eventId,eventHandlerId);

But when I try to run my application, it gives me the error:

java.lang.IllegalArgumentException: EventId(Importar) does not belong to Component(net.ebpartners.sky.MovimientosAlmacen_comp, 32656196)

So, my question is, can this be done?, can I catch an event from a different component?

Thanks in advance

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Daniel,

Of course this can be done - and this is the primary and perhaps only method of interaction from Child Component to Parent component. Have you declared appropriate component usage between the components? If the information flow is from Parent to Child then no eventing is required - this can be done by context mapping through interface view controller. If information flow is from Child to Parent, eventing is required.

Please take a look at [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8d7cd90-0201-0010-4a8c-dd22fa16ca0a] tutorial to solve your issue.

Hope this helps.

Vishwas.

Answers (2)

Answers (2)

Former Member
0 Kudos

Vishwas,

You were right, the problem was I did not declare the component interface controler as a required controler, and when I create the event handler method in the parent component, I could not assign the event to my event hanlder, I follow the tutorial and everything works now,

thanks a lot !!!!

Regards

Daniel

Former Member
0 Kudos

hi

we cann't catch the event from other component,we will get IllegalArgumentException.

we can only fire the event ,which belongs to the same component.

you can only catch the event from component controller.

you can do this.

Declare an Event(Submit) in the componentController.

Declare a button in view,and catch the event by doing like this.

onActionviewaction(....)

{

IWDEventId eventid=wdThis.wdGetFirst_CompController().WD_EVENT_SUBMIT;

IWDEventHandlerId evhandlerid=wdThis.WD_EVENTHANDLER_ON_ACTIONVIEWACTION;

wdComponentAPI.addEventHandler(eventid,evhandlerid);

}

Regards

sowmya.

0 Kudos

Sowmya,

We can catch events from other components as long as that component is declared as a used component. Please go through the article link I posted in my earlier thread. That will be helpful.

Regards,

Vishwas.