Skip to Content
0
Apr 24, 2018 at 06:44 PM

How can I fix this problem: Cannot read property 'indexOf' of undefined

5391 Views

Hi experts.

I'm currently developing a SAPUI5 app and I want to do a little notification section.

I'm doing it with message popover and here is my code:

onInit: function() {
// create any data and a model and set it to the view
this.checkUser();
var oNotif = new sap.ui.model.odata.ODataModel(cnURI, false, "jdiaz", "sineti.01");
var oONotif = new sap.ui.model.json.JSONModel();
oNotif.read("/znoticeSet", undefined, undefined, false,
function(oData, response) {	oONotif.setData(oData);});
this.getOwnerComponent().setModel(oONotif,"notif");
	},

onOpenPopover: function (oEvent) {
	// create popover
if (!this._oPopover) {
this._oPopover = sap.ui.xmlfragment("popoverNavCon", "demo.fragments.NotificationPopOver", this);
this.getView().addDependent(this._oPopover);
			}
	this._oPopover.openBy(oEvent.getSource());
	},

onNavToProduct : function (oEvent) {
   var oCtx = oEvent.getSource().getBindingContext("notif");
   var oNavCon = Fragment.byId("popoverNavCon", "navCon");
   var oDetailPage = Fragment.byId("popoverNavCon", "detail");
         	oNavCon.to(oDetailPage);
		oDetailPage.bindElement(oCtx.getPath());
		},
onNavBack : function (oEvent) {
	var oNavCon = Fragment.byId("popoverNavCon", "navCon");
		oNavCon.back();
		},

And here is my xml fragment:

<core:FragmentDefinition
	xmlns="sap.m"
	xmlns:core="sap.ui.core">
	<Popover
		showHeader="false"
		contentWidth="420px"
		contentHeight="500px"
		placement="Bottom" >
		<NavContainer
			id="navCon">
			<Page
				id="notifications"
				title="Notificaciones">
				<List
					id="list"
					items="{notif>/results}" >
					<StandardListItem
						title="{notif>Head}"
						description="{notif>Fecha}"
						type="Active"
						press="onNavToProduct"
						iconDensityAware="false"
						iconInset="false" />
				</List>
			</Page>
			<Page
				id="detail"
				showNavButton="true"
				navButtonPress="onNavBack"
				title="Notificaciones">
				<ObjectHeader
				title="{notif>Head}" >
				<attributes>
				<ObjectAttribute text="{notif>Subhead}" />
				<ObjectAttribute text="{notif>Content}" />
						</attributes>
				</ObjectHeader>
			</Page>
		</NavContainer>
	</Popover>
</core:FragmentDefinition>

This is my result:

But when I want to consult one element of my list I recive no data and the error that I mentioned before. Here's the images:

And I get this error:

By the way my TileAdmin.controller.js line 67 is this: oDetailPage.bindElement(oCtx.getPath());

I hope you guys can help me!

Best Regards

Attachments

notification.png (22.7 kB)
nolist.png (16.3 kB)
error.png (22.1 kB)