cancel
Showing results for 
Search instead for 
Did you mean: 

When to use custom controller

Former Member
0 Kudos

Hi All.

After going through all docs and tutorials, I don't understand when and why will we use a Custom Controller? Can someone please give me a perfect example for usage of a custom controller?

Thanks .

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Aisha.

In my opinion the custom controller is just used to have a better grouping of

certain functionalities in a component. Which means you

have some views which share the context and methods of a

certain custom controller in order to goup this views.

Cheers,

Sascha

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

<b>When should a custom controller be used?</b>

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:

<b> Reuse</b>

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.

<b> Task separation</b>

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

Regards,

Azaz Ali.

former_member196517
Contributor
0 Kudos

Custom controllers are used to encapsulate units of functionality that are shared by several controllers

and require no direct user interaction. A custom controller is always instantiated as a singleton with

respect to its parent component.

Custom controllers should be used sparingly!

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.

Thanks

Anuj