Basics of XML view in SAPUI5

时间:2015-10-30 21:57:22

标签: sapui5

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.

3 个答案:

答案 0 :(得分:3)

在我看来,主要原因是严格分离关注点。 XML视图本质上排除了代码。因此,您的XML视图是严格的表示逻辑 - 这是专业企业开发的一个重要结果。它还减少了代码输出ui的重要代码行,从而提高了代码的可读性和维护性。

答案 1 :(得分:2)

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.

答案 2 :(得分:2)

如果你说的是为js视图编写的API,这是正确的,因为控件是用JavaScript编写的。如果你的xml中有一个命名空间,就像xmlns:l="sap.ui.layout"任何xml元素一样,前面加上l <l:GridData ... 变成对sap.ui.layout.GridData的调用,如果你看一下这个控件的api,你可以看到你可以添加到这个控件/元素的属性。

此外,如果您的命名空间块中有xmlns="sap.m",则<Page /> <Table />之类的内容会变为sap.m.Pagesap.m.Table,因此api仍然是一个有价值的资源,并且探索的部分很棒看到行动中的控制。