cancel
Showing results for 
Search instead for 
Did you mean: 

custom controller vs component controller

Former Member
0 Kudos

what makes the difference between custom controller and component controller?

can any one explain the difference with sample example?

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

The main difference between custom and component controller is the role which they play during data transfer.

a) Custom controller is used for data transfer across two views within a component. For that you need to bind view context nodes to custom controller either through wizard or manually by adding the code in CTXT class create_contextnode method:

  • initial setting for depandant model node

    coll_wrapper =

      BTADMINH->get_collection_wrapper( ).

    TRY.

        entity ?= coll_wrapper->get_current( ).

      CATCH cx_sy_move_cast_error.

    ENDTRY.

    IF entity IS BOUND.

      BTOpportH->on_new_focus(

                   focus_bo = entity ).

    ENDIF.

b)Component controller is used for data transfer across two views in two different components. For this, we need to define the component usage first and then bind the context nodes in the method-WD_USAGE_INITIALIZE of the Component Controller impl class.

    WHEN 'ComponentUsageName'.

      iv_usage->bind_context_node(

                  iv_controller_type  = cl_bsp_wd_controller=>co_type_custom

                  iv_target_node_name = 'ContextNodeName'  "#EC NOTEXT

                  iv_node_2_bind      = 'ContextNodeName' ).  "#EC NOTEXT

Hope this clears some of your doubts!

Former Member
0 Kudos

hi,

component controller:

Each Web Dynpro component has at least one global controller, called the componentController. The lifetime of the component controller is determined by the lifetime of the entire

Application. Every Web Dynpro controller has a data storage area known as the context. The component controller is the master controller for a Web Dynpro component. As soon as you declare the existence of a Web Dynpro component, the component controller is automatically created.

__Custom controller:_

Needed for storing context data used across several views. A Custom controller has a longer lifecycle than a View controller. Custom controllers belong to the component and live as long as the component lives in an application.

When should custom controller be used:

Reuse Create a custom controller if you have identified a reuse case for a specific unit of code required by several other controllers within the component.

Task separation To avoid placing too much coding in the component controller (and thereby potentially increasing its initialization time), place coding dedicated to a specific task into a separate custom controller

former_member201361
Active Contributor
0 Kudos

hi,

Component Controller The component controller is the master controller for a Web Dynpro component. As soon as you declare the existence of a Web Dynpro component, the component controller is automatically created. You cannot have a Web Dynpro component without a corresponding component controller.

This controller can be thought of as being hierarchically superior to all other controllers in the component. Consequently, the lifespan of the component is always equal to the lifespan of the component controller.

When the Web Dynpro framework receives a URL that corresponds to a Web Dynpro application, the component controller of the root component is instantiated. Here is an example of where the Web Dynpro framework automatically interacts with coding written by the Web Dynpro developer.

Since the component controller has no visual interface, it is incapable of directly presenting any information to the user. This task however, is of no concern to the component controller. The component controller should contain only the coding necessary to control the interaction with:

• All other controllers

• Child component instances

• Model objects

You should regard the component controller as the central point of control for the behaviour of the Web Dynpro component.

Custom controllers are similar to the component controller in that they too have no visual interface. However, the existence of custom controllers is controlled entirely by the Web Dynpro developer at design time. Declaring the existence of a Web Dynpro component causes the component controller to be created automatically, but this is not the case with custom controllers. Custom controllers are only created by an explicit design time declaration.

Former Member
0 Kudos

Component Controller

The component controller provides data and processing logic that it should be possible to display or change for all views of a component. It has three interfaces:

· Interface IF_ for cross-component coding. On the ABAP language level it represents the interface controller .

Within the component, mapping is possible to any context element of the component controller.

The attributes of a component controller are known to all methods that are called within a component and can be used by them, provided they have the Public property. Otherwise, their visibility is restricted to the component controller. Events and methods assigned to the component controller are visible throughout the component. So, for example, any action of a view of the component can call such a method of the component controller.

Custom Controller

The properties and use of the custom controller that can be added optionally correspond exactly to those of the component controller. This means that it is visible to all elements of the component and the lifetime of the elements is the lifetime of the component. The custom controller gives you the option of structuring functions and data within a component. It makes sense to create and maintain a custom controller if a certain subset of views of a component should be equipped with a special function or with a special set of data.

Former Member
0 Kudos

sorry friend faced a server error so the same post got posted twice

Former Member
0 Kudos

go through this link

regards

Noufal

Former Member
0 Kudos

They allow you to structure controller functionality.

For example, controller functionality that is common to different views, but not relevant for the component as a whole, could be placed in a custom controller.

You could not place it in one of the view controllers, because view controllers cannot (and should not) use one another.

Armin

Former Member
0 Kudos

Hi,

Custom Controllers are essentially the same as Component Controllers, but you can create them when

needed.

Create custom controllers when you need to encapsulate separate logic.

You can have multiple Custom Controllers.

Component and Custom Controllers can contain their own source code in the following areas:

Methods, Supply functions and Event Handlers.

Regards, VIP