cancel
Showing results for 
Search instead for 
Did you mean: 

how to throw and handle event defined in component interface

Former Member
0 Kudos

Hi folks,

I have defined a component interface with an event 'open_info'

I have some sub components which are implementing that component interface. I also get the two events generated (the interface check box is not marked)

I use those sub components and try to handle the event. but unfortunately the event is not handled.

I'm not sure if I do everything right. I checked the interface checkbox at the events tab of the controller of the sub component. I then may handle the event in the embedding main component. but it appears to be a different event.

probably I eed to access the interface controller and throw the event there, but I don't know how.

I couldn't fnd documentation or wdr* components which deal with that issue. do you have any suggestions?

regards

stefan

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

In the component controller A Check the Interface checkbox of the Events tab of the component

controller in the table.The corresponding event is passed to the component interface and can

be accessed by an event handler of another component.

In events tab of component A

Event

MY_EVENT

Parameter

MY_PARAMETER type WDY_BOOLEAN

Then raise the event in a method using

WD_THIS->FIRE_MY_EVENT_EV( MY_PARAMETER = u2018Xu2019 ).

endmethod.

In the component controller B where conmponent A is reused here if we want the event handler at view level then

Method Method Type Event Controller

MY_EVENT_HANDLER Event Handler MY_EVENT Component Controller

In method MY_EVENT_HANDLER method we can handle the event.

Former Member
0 Kudos

Hi,

Component Interface X is defining an event A

X is implemented by Component Y

In the Component Controller of Y the u201CInterfaceu201D property needs to be checked

Component Z defines a component usage for Y (or X)

Here make sure that your event handler subscribes to an event coming from the INTERFACECONTROLLER of Y (component usage)

!!!this is on the right hand side of the methods tab in the component controller!!!

Silke

former_member189058
Active Contributor
0 Kudos

Hi Stefan,

Do the following in the component being used:

say component name is ZCMP_01

go to COMPONENTCONTROLLER

Create an Event with necessary parameters if needed, say Event name is EVNT_01 and has an importing parameter, say PARAM_01 type char10,

Make sure you have set the interface check box. Now this event is available in the INTERFACECONTROLLER.

Say ZCMP_01 has a view with a button, on click of the button, call a method in the COMPONENTCONTROLLER.

Perform all the required operations, At the required point, fire EVNT_01


wd_this->fire_EVNT_01_evt(
      PARAM_01 = 'sample' ).

Now the other component that has to use ZCMP_01, say ZCMP_02

In the component properties od ZCMP_02, add usage for ZCMP_01, say USG_CMP_01

Go to the view in ZCMP_02 where you wish to handle the event EVNT_01 of ZCMP_01,

Go to Methods tab, create an event hadler, say EVNT_01_HNDLR ... method type = Event Handler,

Event = EVNT_01, Controller = INTERFACECONTROLLER, Component Use, USG_CMP_01.

Now your event handler will have foll parametrs: WDEVENT .. type ref to CL_WD_CUSTOM_EVENT,

PARAM_01 type CHAR10

Handle the event as required.

Regards,

Reema.

Former Member
0 Kudos

that's what I've done, I know how to throw and handle events, it's just a problem with cross component events. Is there anything special?

>Go to Methods tab, create an event hadler, say EVNT_01_HNDLR ... method type = Event Handler,

>Event = EVNT_01, Controller = INTERFACECONTROLLER, Component Use, USG_CMP_01.

every event comes from interface controller, I don't know what's wrong

former_member189058
Active Contributor
0 Kudos

When you are handling an event from a different component, you need to specify the name of the event and the component usage.

There is a F4 help available on the Event field which will be show all possible interface events in the used component.

Reema.

Edited by: Reema Shahbazkar on Aug 27, 2008 7:59 PM

The kay is basically to raise the event in the componentcontroller of the used component and handle it in the view of the using component.