cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Component Vs Controller and Views

Former Member
1,914

Why do we have to go for Component.js when Controller and View serves the same purpose? What is the advantage of wrapping up the UI fields into a component?

TIA

Accepted Solutions (1)

Accepted Solutions (1)

boghyon
Product and Topic Expert
Product and Topic Expert

A "component", in terms of UI5, usually represents an application with the focus on a specific user role / use case.

In addition, you can describe and assign:

  • Data sources
  • Models
  • Root view
  • Navigation + involved child views
  • Extensions
  • Child components

... and many other application specific settings declaratively.

Without a component, you'd have to do it all manually somewhere in the controller.
Plus, it lets tools analyze and highly optimize your application in the build time.

Encapsulating the application assets enables us to reuse them as a group separately from other assets, such as when defining child components. See Component reuse in manifest.json.

For more information, please go through the topic Structuring: Components and Descriptor.

Answers (1)

Answers (1)

saurabh_vakil
Active Contributor
0 Likes

Component and controller-views do not serve the same purpose. Views are just to declare the UI controls, controllers typically react to view events and user interactions on the screen and act as an interface between the model and view.

Components on the other hand are independent and reusable entities that encapsulate all the UI assets within an application. Components allow the application to be used in more flexible environments like on a Fiori Launchpad, unlike the static index.html page.

Refer SAPUI5 Components

Former Member
0 Likes

Can you please explain how can we reuse the component and also, what are the advantages of encapsulating the UI assets into a component.