Skip to Content

Why do we use XML views rather JS views in SAPUI5?

A very common issue which many of you also have faced in SAPUI5 developments, specially people who are using javascript view to design the UI5 front end.

Important question arises before starting with SAPUI5 application developments, whether to use XML views or JavaScript views. Here are some points I would like to share which you can go through and think to decide upon.

Mostly XML views are used in SAPUI5 developments rather than JavaScript views because:

  1. To protect MVC (Model-View-Controller) guidelines: If a developer uses JavaScript views, then there is chance of putting processing code in the view itself, which violates the MVC principle.
  2. As XML is not a programming language, there is no way you can put processing logic inside XML views. So, in that case, you will always use controller to put your processing logic following MVC architecture.
  3. XML is the industry standard to put views in a UI based application.
  4. The SAP Web IDE includes a WYSIWYG(What you see is what you get) graphical layout editor that works only with XML views.
  5. Using XML views, you can use Layout Editor means Editor that allows you to easily drag and drop UI controls on the screen/page and it’s ready-made code will get available automatically to you.
  6. Parsing of XML in devices is faster than JavaScript.
  7. XML views are more attractive when compared to JS based view.
  8. SAP ships all Fiori apps using XML views. So, as a SAPUI5 developer, better to have atleast the knowledge in how to read XML based views also along with JS views.
  9. SAP recommendation is to use XML views instead of JS, as it is better in terms of maintainability and readability.
  10. You can easily find out the structure and hierarchy of UI controls that are laid out within each other.

MVC architecture:

Everything has its own advantage and disadvantages, you may find those points for both type of views, but it’s in the developer’s hand to decide whichever he/she finds more comfortable.

The main advantage of using XML view is its compatibility to be processed by all the platforms, devices and programming languages.

Moreover, the beauty of XML view is SAPUI5 libraries like sap.ui.core, sap.ui.commons etc. mentioned in a namespace gets loaded by the view itself.(But usually we put those libraries in a Bootstrap code inside index.html).

THINK! and DECIDE! or Just Give it a TRY! 🙂

Be open for new things!!

You must be Logged on to comment or reply to a post.
  • well i do agree on this, SAP recommendation is to use XML views instead of JS.. still many of them using JS and not following SAP standards.  thank you for sharing list, this will help us to show / discuss further Why XML?