Skip to Content

Component Vs Controller and Views

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 04, 2018 at 12:39 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 28, 2018 at 05:21 AM

    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

    Add comment
    10|10000 characters needed characters exceeded