Forum Stats

  • 3,876,244 Users
  • 2,267,083 Discussions
  • 7,912,479 Comments

Discussions

setting Error callback for Collection backed JET paging table.

Smridh Malhotra-Oracle
Smridh Malhotra-Oracle Member Posts: 2 Employee
edited Feb 1, 2022 4:54AM in Oracle JET

I have a JET table, which uses PagingDataProviderView as a backing DataProvider. Since this class wraps a CollectionDataProvider, it essentially accepts a Collection to provide for REST endpoint/url to fetch data.

Now I have a case where, the backing table may not be available at DB, and thus the url for Collection is unable to fetch it. In such a case, the JET Table blocks the UX, while its appearing to still load but no execution really takes place from there on with 400 returned as error.

Is there a way to detect such a scenario happening so as to abort the entire process or maybe set an error callback for PagingDataProviderView to trigger an appropriate error response?


Edit: Basic question I am trying to ask is, How to detect/handle unavailabilty from serviceURL in case of PagingDataProviderView? since it blocks the UX with rows loading, rather than showing 'No rows to display.', like it does in case of CollectionDataProvider automatically?

Tagged:

Answers

  • You would use the "on" event methods on the Collection object. Something like this.

       self.DeptCollection = oj.Collection.extend({
          url: self.serviceURL,
          model: self.myDept,
          comparator: "empno"
        });
    	
        self.DeptCol(new self.DeptCollection());
        self.DeptCol().on('error', self.parseCol);
        self.dataProvider(new CollectionDataProvider(self.DeptCol()));
    

    and the parseCol method looks like

    	self.parseCol = function(collection, xhr, options) {
          console.log("Status: " + xhr.statusText);
          console.log("Status Code: " + xhr.status);
          console.log("Response Text: " + xhr.responseText);
        }
    

    I wrote up this jsFiddle a while back to show how it can work in real code.

    https://jsfiddle.net/peppertech/joeg0rv4/

  • Smridh Malhotra-Oracle
    Smridh Malhotra-Oracle Member Posts: 2 Employee
    edited Feb 5, 2022 9:09AM

    John,

    Thanks for the response. If I handle this event using the 'on' for collection, it does yield the error. And if I use this over a CollectionDataProvider backed table I also see the intended 'No data to display.' message (as in your fiddle).

    However, if I back the table using PagingDataProviderView as follows, it remains in the stuck state.

    this.pagingDataProvider = new PagingDataProviderView(new CollectionDataProvider(studioColl));
    

    where studioColl is a collection object I made.

    The above is the screenshot. Notice how the jet table still appears to be loading as opposed to 'No data to display.' message. This behavior is blocking the UX to act upon the next events.

    So, Is there a way to 'abort' the of PagingDataProviderView backed table, on account of encountering an error through Collection as you explained above?

  • I'll see if I can get an engineer to help out on this one. I'm sure it is possible. The use of PagingControl has been an anti-pattern in the Redwood Design System for the last two years so it's not that often that I deal with it. Need to setup a local repro environment and see what can be done.

    All of the collection based controls have scroll based pagination built-in now and really don't need this outdated paging control approach.

    It may take until Monday to get someone internally to help out. Sorry for the delay,