cancel
Showing results for 
Search instead for 
Did you mean: 

handle event in interface controller

Former Member
0 Kudos

Hi,

I want the interface controller of my component throw events that can be handled by other components using that main component.

so i did:

- create an event in the controller of component a

- create an event handler in the controller interface of the component

the interface controllers event handler tries to write a log entry, but it seems the event handler does not get a notification when the event is thrown, no log entry is written. but i can handle the event in any view of the controller.

where is the problem?

regards

michael

Accepted Solutions (0)

Answers (2)

Answers (2)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Michael,

let me describe your scenario like I understand it:

You fire an event within child component A which is subscribed by the parent component B. The eventing chain goes from child to parent. The other direction (event from parent to child component) is not supported in Web Dynpro yet, because it would require an "external event subscription" which is similar to the "external interface context mapping".

<u><i>Delayed event subsription in SAP NetWeaver 04</i></u>

Your problem is that the event is not handled within the parent component. Why this? This unexpected behavior is probably based on the fact the the Web Dynpro Runtime processes the controller's event subscriptions <b>after</b> the <b>wdDoInit()</b> hook method calls. In SAP NetWeaver 04 the event subsription is not set up yet when the wdDoInit()-method of the component controller is called. Is it possible that you fire this event in the wdDoInit()-method of component controller A?

Could you please give me some more details about your scenario? What's the lifecycle of component A? Is the logging-event only ignored the very first time during the first request response cycle?

Regards, Bertram

Former Member
0 Kudos

Hallo Bertram,

external events is what i wanted later, because it looked to me to be a nice way for solving my problem.

OK, not working. What i tried to do was sth. similar to the excel export component example, but with fixed mapped context instead of sending the context node as parameter of the external method call.

The export scenario used method calls, so you cant create context nodes by drag and drop context nodes (works only from right to left).

So i went on with the idea of eventing - perhaps we should better forget - i should have copied the context of the main comp to the used one and then build the bindings.

Meanwhile i was reading the document "web dynpro for experts" from you, Michael Wenz and Christian Georgi, i think this was pretty much worth reading and cleared up some more things, thanks for that!

Regards,

Michael

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Michael,

now I understand your problem and also know the reason why it is not working:

<b>Web Dynpro Component Interface Controllers are initialized lazily.</b>

This means, that a component interface controller is only being created when ...

<i>a) another controller in the same component has declared a controller usage to it <b>and</b> has accessed the IExternal-API before explicitly (e.g. via method call)

b) another component has declared a component usage to the related component <b>and</b> and the parent component has accessed the IExternal-API of the child component before explicitly (e.g. via method call) or has manually created the child component instance via IWDComponentUsage-API.</i>

In your case the component interface controller is not created and consequently it does not listen to the component controller event.

Your solution should work as soon as this component is embedded in a parent component and is being accessed somehow (e.g. it is part of the current view assembly, it is part a context-mapping chain etc. ...)

Regards, Bertram

Former Member
0 Kudos

Thank you for your help.

Regards,

Michael

Former Member
0 Kudos

Michael,

Let me clear up several points:

- create an event in the <b>interface</b> controller of component A

- <b>create a component usage of A in B </b>

- create an event handler in the controller interface of the component <b>B</b> and <b>defines that it handles events from A</b>

If this is what you mean, then the only reason is that you have to manually call from B:

wdThis.wdGet<NameOfComponentAUsage>().createComponent().

place it, say, into wdDoInit of B's interface / component controller.

VS

Former Member
0 Kudos

Hi Valery,

You guessed what i want to do as next step

But what I first tried was to handle the event fired from <b>component controller A</b> in the <b>interface controller</b> of <b>component A</b>.

I think i have to do so, because the interface controllers eventHandler will raise a new event that can be registered from outside <b>Compnonent B</b>, which has a usage to <b>A</b>

i tried following your advise with the init - but i was not successful.

creation of <b>component A</b> is now in init of <b>component B</b>

perhaps i have to tell that <b>component A</b> is the "main" component that is called first. Can this be the problem?

Former Member
0 Kudos

Michael,

Events should be set from child (nested) to parent (outer).

For communication in other way use method call from parent (outer) on child (nested). Method belongs to child.

Btw, you can raise event defined in intrface controller directly from component controller (within same component) via reference to interface controller.

VS

Former Member
0 Kudos

Hi Valery,

parent-child relation is clear, method usage also. question was if parent must be main called component.

i can only reference the interface controller otherway: comp from interface (arrow from interface to controller)

perhaps i should tell that i want to map parts of the context to the Component B, that is the reason for this.

Hard to explain for me, i hope you understand what i mean.