Skip to Content

Page load error SAPUI5 fregments

  • 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");

} });

});

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Feb 12, 2019 at 03:47 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.