К сожалению, моя страница фрагмента не открывается. Попытка открыть диалог выбора (фрагмент с таблицей) после нажатия кнопки.
Вот ошибка:
formatter function sap.f.FlexibleColumnLayoutWithOneColumnStart.controller.Formatter not found!
Uncaught (in promise) Error: Cannot instantiate object: "new" is missing!
????? at constructor (Object-dbg.js:39:11)
at constructor (EventProvider-dbg.js:29:14)
at constructor (ManagedObject-dbg.js:464:17)
at constructor (Fragment-dbg.js:122:17)
at f._configDialog (DetailDetail.controller.js?eval:120:4)
at f.eval (DetailDetail.controller.js?eval:84:10)
У меня есть Formatter
в папке моего проекта. Свойство _pDialog
кажется пустым, хотя мое представление явно существует.
Ошибка в методе handleTableSelectDialogPress
.
sap.ui.define([
"sap/ui/model/json/JSONModel",
"sap/ui/core/mvc/Controller",
"sap/ui/core/Fragment",
"sap/m/MessageToast",
"./Formatter",
"sap/ui/core/Fragment",
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"sap/ui/model/json/JSONModel",
"sap/ui/core/syncStyleClass",
], function(JSONModel, Controller, Fragment, MessageToast, FilterOperator, syncStyleClass) {
"use strict";
return Controller.extend("sap.f.FlexibleColumnLayoutWithOneColumnStart.controller.DetailDetail", {
// ...,
handleTableSelectDialogPress: function(oEvent) {
var oButton = oEvent.getSource(),
oView = this.getView();
if (!this._pDialog) {
this._pDialog = Fragment.load({
id: oView.getId(),
name: "sap.f.FlexibleColumnLayoutWithOneColumnStart.view.Dialog",
controller: this
}).then(function(oDialog) {
oView.addDependent(oDialog);
return oDialog;
});
}
this._pDialog.then(function(oDialog) {
this._configDialog(oButton, oDialog);
oDialog.open();
}.bind(this));
},
_configDialog: function(oButton, oDialog) {
// ...
syncStyleClass("sapUiSizeCompact", this.getView(), oDialog);
},
// ...
});
});
Это мой взгляд:
<mvc:View displayBlock = "true" controllerName = "sap.f.FlexibleColumnLayoutWithOneColumnStart.controller.DetailDetail" height = "100%" xmlns:mvc = "sap.ui.core.mvc" xmlns = "sap.f" xmlns:m = "sap.m">
<DynamicPage toggleHeaderOnTitleClick = "false">
<!-- ... -->
<content>
<m:Button
class = "sapUiSmallMarginBottom"
text = "Show Table Select Dialog"
press = ".handleTableSelectDialogPress"
ariaHasPopup = "Dialog" />
</content>
</DynamicPage>
</mvc:View>
Это мой Фрагмент:
<core:FragmentDefinition xmlns:core = "sap.ui.core" xmlns = "sap.m">
<TableSelectDialog id = "myDialog"
title = "Select Product"
search = ".handleSearch"
confirm = ".handleClose"
cancel = ".handleClose"
items = "{
path: '/ProductCollection',
sorter: {
path: 'Name',
descending: false
}
}">
<ColumnListItem vAlign = "Middle">
<!-- ... -->
</ColumnListItem>
<columns>
<!-- ... -->
</columns>
</TableSelectDialog>
</core:FragmentDefinition>
Это папка моего проекта:
В массиве есть несоответствие необходимых зависимостей с параметрами обратного вызова фабричной функции контроллера:
sap.ui.define([ "sap/ui/model/json/JSONModel", "sap/ui/core/mvc/Controller", "sap/ui/core/Fragment", "sap/m/MessageToast", "./Formatter", // <-- here you required Formatter "sap/ui/core/Fragment", // <-- required Fragment (again) "sap/ui/model/Filter", "sap/ui/model/FilterOperator", "sap/ui/model/json/JSONModel", // <-- required JSONModel (again) "sap/ui/core/syncStyleClass", ], /*factory*/function(JSONModel, Controller, Fragment, MessageToast,
FilterOperator/*<-- Formatter */,syncStyleClass/*<-- Fragment */) {/* ... */});
Следовательно, параметр syncStyleClass
это нет модуль sap/ui/core/syncStyleClass
но sap/ui/core/Fragment
! И звоню Fragment()
без new
приводит к ошибка "new" is missing!
.
Имя параметров функции не имеет отношения к фреймворку. Важным является правильный порядок этих параметров в соответствии со списком зависимостей. Из Справочник по API sap.ui.define
:
The module export of each dependency module will be provided as a parameter to a factory function, the order of the parameters will match the order of the modules in the dependencies array.
Это же правило относится и к sap.ui.require
.
Отвечает ли это на ваш вопрос? Uncaught TypeError: Fragment.load не является функцией