cancel
Showing results for 
Search instead for 
Did you mean: 

Diff between create component vs extend

Former Member
0 Kudos

HI

I've read about the creating new UI5 control with extend but I found that there is option to use component but

I didnt found any docs about the following

1. what is the difference between them?

2 pros and cons    ?

3. in which cases is recommended to use any of them?

Component docs

https://help.sap.com/saphelp_nw74/helpdata/en/30/1b05f212334a66b1a2bc5411a6c030/content.htm

Thanks

Miley

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

are you asking what is difference between component and control??

Components - UI Development Toolkit for HTML5 (SAPUI5) - SAP Library

Components are independent and reusable parts used in SAPUI5 applications.


Working with Controls in SAPUI5 - UI Development Toolkit for HTML5 (SAPUI5) - SAP Library

Controls are used to define the appearance and behavior of screen areas.




Former Member
0 Kudos

HI Maksim

I already read those docs but this not answered my questions...

Lets say Ive MVC and ui control with addDelegate logic and controller logic and I want

to encapsulate this logic and make it simple control to use by others which approach should I use?

Best Regards,

Miley

former_member182372
Active Contributor
0 Kudos

i would think custom control is the better option

former_member182862
Active Contributor
0 Kudos

HI Miley

It depends on your requirements.

In general, custom control makes your code cleaner and avoid code duplication.

As for logic for controllers. you can have helper functions or base classes for your controllers.

Thanks

-D

Former Member
0 Kudos

HI Dennis,

Do you have any example how to use the helper classes (for controllers) which you mentioned ?

Thank you.

Miley

former_member182862
Active Contributor
0 Kudos

more of a helper functions than helper classes. I guess nothing special about helper functions.

as for base classes

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.core.mvc.Controller

sapui5 controller has extend function for extension.

Maybe you can tell us what you plan to do. And discuss more

-D

Former Member
0 Kudos

Hi Dennis,

Ive MVC with SAPUI5 controls and I want to embed this logic to new control

the delegate event and the controller code to new control that can used simply ,is it possible ?

Do you have any example ?

Thanks,

Miley

former_member182862
Active Contributor
0 Kudos

HI Miley

I am trying to understand your question. Maybe it is easier to have an example.

For example, you have a new Control, ControlABC. And you want to have a common logic (alert('Hello World') in the click delegate. On top of this you want controller code in the control.

I do not advocate having controller code in control. The common logic in control is ok.

Thanks

-D

Answers (0)