Skip to Content
0
Former Member
Apr 12, 2016 at 08:40 AM

Master-Detail bindingContext error

435 Views

Hi guys,

I have a problem with my binding context. When I click on a enry in the master view, the detail view should be refreshed. Instead I get the following error: Uncaught TypeError: Cannot read property 'getProperty' of undefined

What I have done:

The master list is dynamic, so I removed the binding (which was generated from the template) of the master view and did the binding in the controller.

Now I got the following coding:

Master.view.xml (the changed/important code is bold):

<mvc:View

controllerName="xyz.controller.Master"

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

xmlns:core="sap.ui.core"

xmlns="sap.m"

xmlns:semantic="sap.m.semantic">

<semantic:MasterPage

id="page"

title="{masterView>/title}"

navButtonPress="onNavBack"

showNavButton="true">

<semantic:subHeader>

<Bar id="headerBar">

<contentMiddle>

<SearchField

id="searchField"

showRefreshButton="{= !${device>/support/touch} }"

tooltip="{i18n>masterSearchTooltip}"

width="100%"

search="onSearch">

</SearchField>

</contentMiddle>

</Bar>

</semantic:subHeader>

<semantic:content>

<PullToRefresh

id="pullToRefresh"

visible="{device>/support/touch}"

refresh="onRefresh" />

<!-- For client side filtering add this to the items attribute: parameters: {operationMode: 'Client'}}" -->

<List

id="list"

busyIndicatorDelay="{masterView>/delay}"

noDataText="{masterView>/noDataText}"

mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"

growing="true"

growingScrollToLoad="true"

updateFinished="onUpdateFinished"

selectionChange="onSelectionChange">

<infoToolbar>

<Toolbar

active="true"

id="filterBar"

visible="{masterView>/isFilterBarVisible}"

press="onOpenViewSettings">

<Title

id="filterBarLabel"

text="{masterView>/filterBarLabel}" />

</Toolbar>

</infoToolbar>

<items>

<ObjectListItem

type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}"

press="onSelectionChange"

title="{Aufpl}"

>

</ObjectListItem>

</items>

</List>

</semantic:content>

</semantic:MasterPage>

</mvc:View>

Master.controller.js (only the first 10 lines changed, after this it is unchanged)

onInit: function() {
       var sOrderNumber = jQuery.sap.getUriParameters().get("OrderNumber");
       var oList = this.byId("list");
       var oObjectListItem = new sap.m.ObjectListItem({
            title: "Plannummer {xyz>Aufpl}",
            type: "Inactive",
            intro: "Zähler {xyz>Aplzl}"
            }
       );
    oList.bindAggregation("items", "xyz>/ProductionOrderSet('" + sOrderNumber + "')/OrderOperationSet", oObjectListItem);


  // Control state model
  // var oList = this.byId("list"),
  var oViewModel = this._createViewModel(),
  // Put down master list's original value for busy indicator delay,
  // so it can be restored later on. Busy handling on the master list is
  // taken care of by the master list itself.
  iOriginalBusyDelay = oList.getBusyIndicatorDelay();


  this._oList = oList;
  // keeps the filter and search state
  this._oListFilterState = {
  aFilter: [],
  aSearch: []
  };


  this.setModel(oViewModel, "masterView");
  // Make sure, busy indication is showing immediately so there is no
  // break after the busy indication for loading the view's meta data is
  // ended (see promise 'oWhenMetadataIsLoaded' in AppController)
  oList.attachEventOnce("updateFinished", function() {
  // Restore original busy indicator delay for the list
  oViewModel.setProperty("/delay", iOriginalBusyDelay);
  });


  this.getView().addEventDelegate({
  onBeforeFirstShow: function() {
  this.getOwnerComponent().oListSelector.setBoundMasterList(oList);
  }.bind(this)
  });


  this.getRouter().getRoute("master").attachPatternMatched(this._onMasterMatched, this);
  this.getRouter().attachBypassed(this.onBypassed, this);
},

On clicking an entry in the master view calls this (unchanged) function:

onSelectionChange: function(oEvent) {
  // get the list item, either from the listItem parameter or from the event's source itself (will depend on the device-dependent mode).
  this._showDetail(oEvent.getParameter("listItem") || oEvent.getSource());
},

and this one calls the function where the error occurs (line 4)

_showDetail: function(oItem) {
  var bReplace = !Device.system.phone;
  this.getRouter().navTo("object", {
  objectId: oItem.getBindingContext().getProperty("Aufpl")
  }, bReplace);
},

Can anybody help me with this problem?

Best regards,

Bastian