We're currently evaluating SAP's OpenUI5 in the context of a new project.
While most examples and tutorials tend to construct views using XML, out of personal preference I'd choose Javascript for the task. However I haven't poked around in OpenUI5 long enough to identify any specific strengths for either approach.
Are there any disadvantages in using JS? Or advantages even?
Many Thanks!
Update:
I agree with SDD64's answer. After using both approaches in parallel for a while, I can add the following pros and cons to the list:
XML advantages:
XML disadvantages:
I am also a fan of JS based views. Possible (dis)Advantages are in my eyes:
Advantages for JS
Disadvantages for JS
** Update 2015-06-18 **
With the current OpenUI5 1.28 supporting conditions in XML views and the recently previewed 1.30 supporting binding for dynamic loading of XML fragments , I felt the need to update my answer.
With those new features, XML views gained a "healthy" amount of flexibility. Making them, for me, more attractive when compared to JS based view.
It's all in the eyes of the developer. Some devs will prefer to write html5 like (xml) views, other will prefer the feeling in control with the js views. Small disadvantage of the xml views is the extra step to convert them to js code. They should be a bit (neglitable) slower.
You can build your pages dynamically with XML-Views:
Controller
sap.ui.controller("my.own.controller", {
onInit: function () {
var jsonData = {
simpsons: [
{name: "Marge", gender: "female"},
{name: "Homer", gender: "male"},
{name: "Bart", gender: "male"},
{name: "Lisa", gender: "female"},
{name: "Maggi", gender: "female"},
{name: "Snowball1", gender: "female"},
{name: "Ruprecht", gender: "male"}
]
};
var oModel = new JSONModel(suggJSON);
this.setModel(oModel, "myJsonModel");
},
});
View :
<core:View
xmlns:core="sap.ui.core"
xmlns:m="sap.m"
xmlns="sap.ui.commons"
xmlns:html="http://www.w3.org/1999/xhtml"
>
Content of Model:
<m:VBox items="{myJsonModel>/simpsons}">
<Button text="{myJsonModel>name} visible="{= ${myJsonModel>gender} === 'male'}"/>
<Text text="{myJsonModel>name} visible="{= ${myJsonModel>gender} === 'female'}"/>
</m:VBox>
</core:View>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.