Reputation: 1826
I've been studying sapui5 framework for some time now and I always used javascript views in my applications.
The question is - are there reasons why should I prefer xml views over javascript, if I should do it at all? If there are some, what are they?
If I want to start trying to write xml views, what is the best place to learn the basic syntax and where can I find API reference for controls created using xml? The SAPUI5 API is written for use with javascript.
Thanks.
Upvotes: 0
Views: 3364
Reputation: 386
Where you say the API is written for js views, this is true because the controls are written in JavaScript. Look at it this way if you have a namespace in your xml like xmlns:l="sap.ui.layout"
any xml element prepended with l like <l:GridData ...
becomes a call to sap.ui.layout.GridData
and if you look at the api for this control you can see what attributes you can add to this control / element.
Also if you have xmlns="sap.m"
in your namespace block then anything like <Page /> <Table />
become sap.m.Page
or sap.m.Table
so the api is still a valuable resource and the explored section is great to see controls in action.
Upvotes: 2
Reputation: 1238
Major reason, in my view, is strict separation of concerns. XML views, by their nature, preclude code. Your XML view is therefore strictly presentation logic - a great outcome for professional enterprise development. It also reduces the significant lines of code to code out the ui and thus improves readability and maintenance of code.
Upvotes: 3
Reputation: 360
the reason I use XML views is because this is the standard approach of the Fiori apps by SAP. It creates a situation where developers only have 1 approach. Also to me they are easier readable.
Generally speaking I see that in the mobile library the xml views are used while in desktop usage js is still leading. On SCN you can find many similar questions.
The library of examples can be found in the same API page under tab EXPLORED.
Perhaps using the webIDE (which offers a local) install can provide a really good base for you to start development using xml based views.
Upvotes: 2