cancel
Showing results for 
Search instead for 
Did you mean: 

Use of Controllers

Former Member
0 Kudos

hi all,

when and why shuould we use a custom controller ?

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Why Custom Controller?

Custom controllers are used to encapsulate units of functionality that are shared by several controllers and require no direct user interaction. Such controllers therefore have no visual interface.

For instance, a custom controller could be used, when a BAPI is called, and the information returned requires some sort of intermediate processing before it can be displayed.

If you have any additional functionality mainly if you think itu2019s too much burden for existing Component Controller optionally you can be added this to the newly created Custom 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.

*When to use?

Before implementing a custom controller, consider carefully whether its presence will simplify or complicate the overall architecture of your application.

Custom controllers should only be added in situations that will optimize or simplify the architecture of your application.

Information held in the context of a custom controller can be made accessible to the context of another controller (view or custom) by a technique known as context mapping. Using this technique, two or more controllers can access the same runtime data. This is the primary mechanism for sharing data between controllers within a single component.

Lifespan :

The lifespan of a component is defined by, and equal to, the lifespan of the component controller. All custom controller instances exist for as long as their parent component exists and are instantiated automatically by the Web Dynpro framework. After the component controller has been instantiated, the order in which any subsequent custom controllers are instantiated is undefined. Therefore, the coding in a custom controller should make no assumptions about the existence of any other custom controller.

Some Notes:

All custom controllers are instantiated as singletons with respect to their parent component.

Custom controllers are instantiated automatically by the Web Dynpro Framework and the instantiation order is undefined! All controllers are independent programs yet none function in isolation from the other controllers in the component.

All custom controllers store their runtime data in a hierarchical data storage area known as the Context.Unless an explicit controller usage is declared, all the data in a controlleru2019s context is private. Custom controller may share their context data.

More help please refer the below links:

https://www.sdn.sap.com/sdn/collaboration.sdn?contenttype=url&content=https%3A//forums.sdn.sap.com/t...

/thread/464134 [original link is broken]

http://help.sap.com/saphelp_nw2004s/helpdata/en/b9/b82c4142aef623e10000000a155106/content.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/b9/b82c4142aef623e10000000a155106/content.htm

http://wendtstud1.hpi.uni-potsdam.de/sysmod-seminar/SS2005/presentations/12-WebDynpro-Overview.pdf

http://branfran.com/Files/Web%20Dynpro%20for%20beginners%20Presentation.pdf

Thanks

Krishna

vmadhuvarshi_
Contributor
0 Kudos

Akhilesh,

Don't use Custom Controller unless you have a very compelling reason to do so. Custom controller may be required when you need to use an inner class - like when you are implementing a Object Value Selector but if you are using Custom Controller to serve as a reusable service object, IMHO, developing a separate faceless DC will be a better choice.

A Component Controller is like a Custom Controller by definition and is available by default. So, unless otherwise required, using it is a better way of saving time and efforts.

Hope this helps.

Vishwas.

Former Member
0 Kudos

Hello Akilesh,

The custom controller is similar as component controller.

The custom controller is used when we use large webdynpro components

However, from a design perspective it might be better to split a big web dynpro component in to several smaller components instead.

One does need custom controllers when one wants to use explicit component configuration. Then the custom controller will be marked as "configuration controller".

Regards,

Arun

PradeepBondla
Active Contributor
0 Kudos

Hi,

You could have checked/searched in SDN, its been discussed many times

in words of AZAZ in this following thread

*When should a custom controller be used?*

Custom controllers should be created only when their presence will simplify the overall structure of the component. The principles to follow for deciding when a custom controller is needed are:

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

PradeeP

sureshmandalapu6
Active Contributor
0 Kudos

Hi akhilesh singh ,

A custom controller is a special type of controller of a Web Dynpro application, which the Web Dynpro application developer can create explicitly if required. Like all other controller types, the custom controller contains a context class, which is automatically generated when the custom controller is defined. Furthermore, the custom controller contains imported packages and methods that are then relevant to all classes in a Web Dynpro application. The custom controller is also the part of an application that implements the event handlers and validators that react to actions.

You can define more than one custom controller for a Web Dynpro application. Before starting the application, you use a reference to specify which custom controller is to be valid at runtime. The lifetime of a custom controller is linked to the lifetime of the entire Web Dynpro application.

http://help.sap.com/erp2005_ehp_03/helpdata/EN/c4/862594e85911459301aa71a2b7b6b4/frameset.htm

Thanks

Suresh