cancel
Showing results for 
Search instead for 
Did you mean: 

Split App throws getBindingContext(...) is undefined

former_member589109
Participant
0 Kudos

Hi,
I'm creating a simple Split App using a template.
Because of the OData service specification, I had to make some changes to the manifest file and in the master.controller as well.
While starting the app I'm receiving
TypeError: mParams.firstListitem.getBindingContext(...) is undefined
In the console.
What am I doing wrong and how to repair this bug?
The manifest file and other parts of the app are good because the navigation works fine if I click anything on Master list, but it can't show first list element details by default.
Here is the code of problematic functions:

onInit: function() {
            var oList = this.byId("list"),
                oViewModel = this._createViewModel(),
                iOriginalBusyDelay = oList.getBusyIndicatorDelay();

            this._oList = oList;
            this._oListFilterState = {
                aFilter: [],
                aSearch: []
            };

            this.setModel(oViewModel, "masterView");
            oList.attachEventOnce("updateFinished", function() {
                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);
        },

_onMasterMatched: function() {
            
            this.getOwnerComponent().oListSelector.oWhenListLoadingIsDone.then(
                function(mParams) {
                    if (mParams.list.getMode() === "None") {
                        return;
                    }
                    
                    var sObjectId = mParams.firstListitem.getBindingContext().getProperty("Bukrs");
                    var sObjectId2 = mParams.firstListitem.getBindingContext().getProperty("Auditid");
                    var sObjectId3 = mParams.firstListitem.getBindingContext().getProperty("Commiteeid");
                    this.getRouter().navTo("object", {
                        objectId: sObjectId,
                        objectId2: sObjectId2,
                        objectId3: sObjectId3
                    }, true);
                }.bind(this),
                function(mParams) {
                    if (mParams.error) {
                        return;
                    }
                    this.getRouter().getTargets().display("detailNoObjectsAvailable");
                }.bind(this)
            );
        },

Accepted Solutions (0)

Answers (4)

Answers (4)

Did you give your ODATA model a name inside of your manifest? Or change the named model of the master list?

So for example, If I have an ODATA service called "myService" It would be .getBindingContext("myService") and the same applies to a differntly named model for your master list.



former_member589109
Participant
0 Kudos

This is from the manifest

"dataSources": {
            "mainService": {
                "uri": "/SRV/sap/opu/odata/PRJ/PRJ_SRV/",
                "type": "OData",
                "settings": {
                    "odataVersion": "2.0",
                    "localUri": "localService/metadata.xml"
                }
            }
        },

"models": { "i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "prj.i18n.i18n" } }, "": { "dataSource": "mainService", "preload": true, "settings": { "defaultBindingMode": "TwoWay" } } },
former_member306541
Participant

I have never seen an URI beginning with "/SRV". All our URIs start with "/sap/opu/odata/".

But I do not think, that this is problem, because all communication to the ODataService should cause errors in this case. But to be sure, can you verifiy in the network pane of the debugger tools of your browser, that i.e. metadata of your odata service is loaded.

If metadata is loaded, you can take a deeper look inside mParams.firstListitem. Is this the right object? Who assigned it to mParams?

former_member589109
Participant
0 Kudos

About the /SRV - for some reason, it's needed while I'm using the local IDE, but I have to remove it manually before deploying the app, and the communication between app and OData works fine (it reads, puts and updates data without a problem).
The mParams.firstListitem seems to be wrong since it's oModels and oBindingContexts are empty objects.

former_member306541
Participant

Hi Bartosz,

if your List is bound to "masterView" Model, you have to call mParams.firstListitem.getBindingContext("masterView").getProperty("Bukrs")

Best regards,

Christian.

former_member589109
Participant
0 Kudos

Thanks for your reply, but after changing to

var sObjectId = mParams.firstListitem.getBindingContext("masterView").getProperty("Bukrs");
There is still the same behaviour and the same error in the console.
Of course, I've changed all three getBindingContext parts accordingly.

former_member589109
Participant
0 Kudos

After removing

,group : true

from the

<List items="{ path: '/CommitteeSet', sorter: { path: 'Auditid', descending: false} }"[...]

in Master.view.xml the error stopped appearing.
Why does grouping have an impact on that?

junwu
Active Contributor
0 Kudos
you need show a bit more information about this piece, this.getOwnerComponent().oListSelector.oWhenListLoadingIsDone.