0
votes

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>
2
What's the UI5 version you're using (sap.ui.version)? - Boghyon Hoffmann
Hi..i have the latest version - rs9
So, what do you get when you enter sap.ui.version in runtime on your browser console? The fact that the same code works fine with <end/beginButton> indicates that the current version is below 1.21.1 since Dialog didn't have the buttons aggregation until then. The only mistake I can see right now are the invalid icon paths: Instead of icon="sap.icon://..., it should be icon="sap-icon://.... But that's not the main issue here. Do you use somewhere else buttons in your application? - Boghyon Hoffmann
Must be the case! coz my version is 1.20.7.let me install the latest version and run the application. many thanks :) - rs9

2 Answers

0
votes

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

0
votes

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.