Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Collection stuck in a loop on refresh

2649983Jun 6 2019 — edited Nov 19 2019

Hi,

This might be a little difficult to explain.

I have a table which i display inside a dialog which uses PagingDataProviderView.

I need the collection to refresh every time I open or close the dialog.

function openDialog(event) {

    if (!event.key || event.key !== "Tab") {

        document.getElementById(`${vm.id}_dialog`).open();

        if (vm.firstOpen) {

            vm.reportSource(new PagingDataProviderView(

                new CollectionDataProvider(vm.reportCollection()),

            ));

            vm.firstOpen = false;

        } else {

            vm.reportCollection().refresh();

        }

    }

}

vm.ReportModel = Model.Model.extend({

    idAttribute: "id",

});

vm.ReportCollection = Model.Collection.extend({

    customURL: getURL,

    model: new vm.ReportModel(),

    parse: parseResponse,

    customPagingOptions: pagingOptions,

    fetchSize: vm.pageSize(),

});

vm.reportCollection = ko.observable(new vm.ReportCollection());

vm.reportSource = ko.observable();

This works fine as long as I don't make a selection on the table. Every time I open the dialog, the collection refreshes.

However, if I make a selection and open the dialog again, the collection gets stuck in a refresh loop.

The backing service for the collection is called multiple times and returns the exact same data.

If I close the dialog while the refresh is stuck in a loop, it stops calling the service and when i open it again, it calls the service just once and displays the data.

In the getURL method, when it works, the options parameter is a plain object.

When it goes into the infinite loop, every call to getURL sends a deferred object as the options parameter.

Does that mean the collection interface is not registering that the required records have been fetched?

I'm really confused. I have done something similar with a list view in a dialog and that seems to work without any trouble.

Thanks,

William.

Comments
Post Details
Added on Jun 6 2019
2 comments
185 views