Error While Creating a Dialog Box Using XML Fragments

别等时光非礼了梦想. 提交于 2019-12-24 20:31:54

问题


I am getting the below error while trying to display a dialog box after user presses a button,

sap-ui-core.js:80 Uncaught Error: failed to load 'sap/m/buttons.js' from resources/sap/m/buttons.js: 404 - Resource could not be found!

Please find the XML code below.

<Dialog xmlns="sap.m"
  icon="sap.icon://filter"
  title="Filter product details">
  <content>
    <List id="ls2"
      items="{/value}"
      mode="MultiSelect">
      <StandardListItem title="{CompanyName}"/>
    </List>
  </content>
  <buttons>
    <Button text="ok" icon="sap-icon://accept" press="handleok"/>
    <Button text="Cancel" icon="sap.icon://cancel"/>  
  </buttons>
</Dialog>

回答1:


So the issue was that the UI5 version was quite outdated after all. The aggregation buttons was introduced as of version 1.21.1.




回答2:


You have to wrap the sap.m.Dialog control inside a FragmentDefinition according to the walkthrough guide.

Here is minimal example https://embed.plnkr.co/OjUCXTg2afohZyDvPp67/

<core:FragmentDefinition
    xmlns="sap.m"
    xmlns:core="sap.ui.core">
    <Dialog
        id="helloDialog"
        title="Hello World">
      <buttons>
        <Button text="Ok">
        <Button text="Cancel">
      </buttons>
    </Dialog>
</core:FragmentDefinition>

And instead of using a dialog control you can use a sap.m.MessageBox control which provides you with "Ok" and "Cancel" or custom buttons.



来源:https://stackoverflow.com/questions/48839161/error-while-creating-a-dialog-box-using-xml-fragments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!