cancel
Showing results for 
Search instead for 
Did you mean: 

Design question: Interface Controller vs. component controller

Former Member
0 Kudos

Hello,

I have a component A. This component has a component controller (compController) and an interface controller (intController).

Component controller has method compMethod()

Interface controller has method intMethod()

- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)

- Am i allowed to call compMethod from intController or is this bad design?

- Am i allowed to subscribe compController to event in intController or is this bad design?

Kind regards,

Joren

Accepted Solutions (0)

Answers (2)

Answers (2)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Joren,

like Valery already pointed out, we recommend not to implement any logic in the component interface controller but only implement methods used for delegating logic to the component controller. This is based on the fact, that the component interface controller will be implemented by the component controller in the the next major SAP NetWeaver Release. This means that it will not have its own Java class like in NW04 and NW04s. To simplify migration the interface controller code should be as slim as possible by applying the delegation principle.

You wrote:

<i>- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)</i>

Yes, my (very old) tutorial on serverside eventing exposes a public method <i>fireEvent()</i> which is invoked by the component controller. In early versions of NW04 the wdFireEventInnerEvent() method was not exposed in the IPublic-API of the component interface controller but only in the IPrivate-API. Therefore an additional method fireEvent() must be defined to fire the event from another controller. As a negative side effect, this public fireEvent() method is also exposed by the IExternal-API of the component interface controller so that the event can be fired from outside (by the Embedder component) which is not desired in most cases.

Meanwhile the wdFire<event name>() method is exposed by the IPublic-API of the component interface controller, so that the public method fire<Event name>() is no longer needed.

I will update the tutorial in this respect so that it again propagates best practices.

Regards, Bertram

Former Member
0 Kudos

So this means that in the Diagram View in NWDS there's:

1. add Component Controller to required controllers of Interface Controller (for forwarding methods to the ComponentController)

2. add Interface Controller to required controllers of Component Controller (for external context mapping)

In the diagram view this results in a two way arrow (two arrows on top of each other actually). With double clicking that arrow, you can only reach one

Greetz,

Joren

Message was edited by: Joren Crauwels

Former Member
0 Kudos

Joren,

<i>So this means that in the Diagram View in NWDS there's:

1. add Component Controller to required controllers of Interface Controller (for forwarding methods to the ComponentController)

2. add Interface Controller to required controllers of Component Controller (for external context mapping)</i>

Unfortunately, yes. And you even get [safely ignorable in this case] warning about cycle in required controller usages. Currently there is no way to avoid such warning when you both call methods on component controller and fire events/map contexts of/from interface controller.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Thx for the explanation.

Joren.

Former Member
0 Kudos

Joren,

<i>- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)</i>

Yes, it is possible, however this is bad design though it is used in tutorial

See, that assumes that method in interface controller has some logic. However, intent of interface controller is only to expose functionality available in other controllers (component controller and custom controllers). There are some comments that in further WD versions interface controller will be in fact interface (in Java sence), so prepare early -- do not put logic in interface controller and simplify migration of components in future.

<i>- Am i allowed to call compMethod from intController or is this bad design?</i>

Doch! You should use this approach, this is correct and recommended design.

<i>- Am i allowed to subscribe compController to event in intController or is this bad design?</i>

Also possible, but smells like the first one. Again, interface is exposing functionality, do not overload it with implementation.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net