Why do we use XML views rather JS views in SAPUI5?
- 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.
- XML is the industry standard to put views in a UI based application.
- The SAP Web IDE includes a WYSIWYG(What you see is what you get) graphical layout editor that works only with XML views.
- 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.
- XML views are more attractive when compared to JS based view.
- 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.
- SAP recommendation is to use XML views instead of JS, as it is better in terms of maintainability and readability.
- You can easily find out the structure and hierarchy of UI controls that are laid out within each other.
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!!