cancel
Showing results for 
Search instead for 
Did you mean: 

Page load error SAPUI5 fregments

dilsher
Explorer
0 Kudos
  • unable to show show the fragment data inside the xml view.showing page laod error help me to resolve it.

(Hellodialog.xml).....fregment file

<core:FragmentDefinition

xmlns="sap.m" xmlns:core="sap.ui.core">

<Dialog id="helloDialog"

tittle="Hello {/recipient/name}">

</Dialog>

</core:FragmentDefinition>

----------------------------------------------------------------------------------------

HelloPanel.view,xml....Xml View code


<mvc:View

xmlns:core="sap.ui.core"

xmlns:mvc="sap.ui.core.mvc"

xmlns="sap.m"

controllerName="demo1.Fregments.controller.HelloPanel"

xmlns:html="http://www.w3.org/1999/xhtml">

<Panel

headerText="{i18n>helloPanelText}"

width="auto">

<content>

<Button

text="{i18n>ButtonShowPanel}"

class="sapUiResponsiveMarginEnd"

press="onShowHello"/>

<Input

value="{/recipient/name}"

valueLiveUpdate="true"

width="60%"/>

<Button

text="{i18n>ButtonShowDialog}"

id="helloButtonPanel"

press="onShowDialog"

class="sapUiResponsiveMarginEnd"/>

</content>

</Panel>

</mvc:View>

-----------------------------------------------------------------------------------------

HelloPanel.controller.js ..file

sap.ui.define([

"sap/ui/core/mvc/Controller",

"sap/m/MessageToast",

"sap/ui/core/Fragment" ],

function (Controller, MessageToast, Fragment){

"use strict";

return Controller.extend("demo1.Fregments.controller.HelloPanel", {

onInit: function () {

},

onShowHello: function () {

var oBundle = this.getView().getModel("i18n").getResourceBundle();

var sRecipient = this.getView().getModel().getProperty("/recipient/name");

var sMsg = oBundle.getText("helloMsg", [sRecipient]);

MessageToast.show(sMsg);

},

onOpenDialog: function () {

var oView = this.getView();

// create dialog lazily

if (!this.byId("helloDialog"))

{

// load asynchronous XML fragment

Fragment.load({

id: oView.getId(),

name: " demo1.Fregments.view.Hellodialog "

}).then(function (oDialog) {

// connect dialog to the root view of this component

oView.addDependent(oDialog);

oDialog.open();

});

} else {

this.byId("helloDialog").open();

} }

});

});

---------------------------------------------------------------------------------

Component.js file...


sap.ui.define([

"sap/ui/core/UIComponent",

"sap/ui/Device", "demo1/Fregments/model/models" ],

function (UIComponent, Device, models) {

"use strict";

return UIComponent.extend("demo1.Fregments.Component", {

metadata: {

manifest: "json"

},

init: function () {

UIComponent.prototype.init.apply(this, arguments);

var oData = {

recipient: {

name: "World"}

};

var oModel = new sap.ui.model.json.JSONModel(oData);

this.setModel(oModel); this.getRouter().initialize();

this.setModel(models.createDeviceModel(), "device");

} });

});

Fabrice
Active Participant

Hi,

could you be more precise about the error message. (maybe with a screenshot of the error and/or of the debugger console)?

Thanks

Regards,

Fabrice

maheshpalavalli
Active Contributor
0 Kudos

Can you also format the code.. there will be an option in the toolbar (CODE).. click that and insert the code which comes formatted

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member467961
Participant
0 Kudos

Hello,

one observation is that the function to open Dialog fragment is named as onOpenDialog inside HelloPanel Controller, while inside the HelloPanel view you are calling an undefined function onShowDialog.

Thanks & Kind Regards,

Bopanna