Visual Builder

Get Involved. Join the Conversation.

Topic

    Guy Lior
    Pagination error in new version of VBCS (19.3.1.2)Answered
    Topic posted October 10, 2019 by Guy LiorBronze Medal: 1,250+ Points 
    114 Views, 30 Comments
    Title:
    Pagination error in new version of VBCS (19.3.1.2)
    Summary:
    Pagination error in new version of VBCS (19.3.1.2)
    Content:

    Since the new version of VBCS (19.3.1.2) I am getting the following error , was working on previous version for sure

    Error: getConfig() for "<endpoint name>" is missing required parameters: "offset", "limit"

    Any idea?

    Best Comment

    John Ceccarelli

    how is the endpoint being used? is it in an SDP that is bound to a table/list?

    Comment

     

    • John Ceccarelli

      how is the endpoint being used? is it in an SDP that is bound to a table/list?

      • Guy Lior

        Custom endpoint using SDP bounded to a list.

        endpoint support limit, offset, has_more, totalCount. 

        transforms script is used

        for sure it worked before the upgrade

    • John Ceccarelli

      can you post the JSON for the SDP and your transforms JS here?

      • Guy Lior

        Transforms:

        //
        // Example code, not for use in production environments.
        //
        define(['urijs/URI'], function (URI) {
            'use strict';

            var Request = function () {
            };

            /**
             * Filter transform function
             * @param configuration
             * @param options the JSON payload that defines the filterCriteria
             * @returns {object} configuration object the url looks like ?filter=foo eq 'bar'.
             */
            Request.prototype.filter = function(configuration, options) {
                var filterCriterion = options;

                function jetFilterOpToScim(fop) {
                    switch (fop) {
                        case '$eq':
                            return 'eq';
                        case '$ne':
                            return 'ne';
                        case '$co':
                            return 'co';
                        default:
                            console.warn('unable to interpret the op ' + fop);
                            return null;
                    }
                }

                function isEmpty(val) {
                    return (val === undefined || val === null || val === '');
                }

                if (typeof filterCriterion === 'object' && Object.keys(filterCriterion).length > 0) {
                    if (filterCriterion.op && filterCriterion.attribute && !isEmpty(filterCriterion.value)) {
                      var atomicExpr = {};
                      atomicExpr.op = jetFilterOpToScim(filterCriterion.op);
                      atomicExpr.attribute = filterCriterion.attribute;
                      atomicExpr.value = filterCriterion.value;

                      if (atomicExpr.op && atomicExpr.attribute) {
                        configuration.url = URI(configuration.url).addQuery({
                          filter: atomicExpr.attribute + ' ' + atomicExpr.op + ' ' + atomicExpr.value
                        }).toString();
                      }
                    }
                }

                return configuration;
            };

            /**
             * Pagination function appends limit and offset parameters to the url
             * @param configuration
             * @param options the JSON payload that defines the pagination criteria
             * @returns {object} configuration object.
             */
            Request.prototype.paginate = function(configuration, options) {
                
                console.log("ZZZ PAGINATION");
                console.log("ZZZ PAGINATION configuration "+JSON.stringify(configuration));
                console.log("ZZZ PAGINATION options "+JSON.stringify(options));
                
                var newUrl = configuration.url;
                newUrl = URI(newUrl).addSearch({limit: options.size, offset: (options.offset / options.size )}).toString();
                configuration.url = newUrl;
                
                console.log("ZZZ PAGINATION newUrl: "+ newUrl);
                
                return configuration;
            };

            /**
             * Sort transform function
             * @param configuration
             * @param options the JSON payload that defines the sort criteria
             * @returns {object} configuration object. the url looks like ?orderBy=foo:asc
             */
            Request.prototype.sort = function(configuration, options) {
                if (Array.isArray(options) && options.length > 0) {
                    var firstItem = options[0];
                    if (firstItem.attribute) {
                        var dir = firstItem.direction === 'descending' ? 'desc' : 'asc';
                        var newUrl = configuration.url;
                        newUrl = URI(newUrl).addSearch({orderBy: firstItem.attribute + ':' + dir}).toString();
                        configuration.url = newUrl;
                    }
                }
                return configuration;
            };

            var Response = function() {

            };

            /**
             * Paginate Response Transform Function Implementation
             */
            Response.prototype.paginate = function(result) {
                
                 console.log("ZZZ Response PAGINATION");
                 console.log("ZZZ Response PAGINATION "+JSON.stringify(result));
                
                var tr = {};

                if (result && result.body) {
                    var cb = result.body[0];
                    if (cb.totalCount) {
                        tr.totalSize = cb.totalCount;
                    }
                    if (cb.totalCount >= 0) {
                        tr.hasMore = !!cb.hasMore;
                    } else {
                        tr.hasMore = false;
                   }
                }
                
                console.log("ZZZ Response PAGINATION TR "+JSON.stringify(tr));
         
                return tr;
            };

            return {
                request: Request,
                response: Response
           };
        });

      • Guy Lior

        JSON:

        [
            {
                "Row_id": 1110,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "123456",
                "Length": 600,
                "Diameter": "86",
                "Action": "Grinding",
                "Date_Time": "2019-10-06T14:46:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1107,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "11111111",
                "Length": 650,
                "Diameter": "95",
                "Action": "",
                "Date_Time": "2019-10-06T14:15:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1106,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "",
                "Length": 770,
                "Diameter": "125",
                "Action": "Grinding after coating",
                "Date_Time": "2019-10-06T14:13:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1104,
                "Site": "MMM",
                "Department": "BBB",
                "Side_Roller_Number": "",
                "Length": 450,
                "Diameter": "",
                "Action": "",
                "Date_Time": "2019-10-06T14:08:00.000+02:00",
                "Login_Name": "",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1102,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "1",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding after Coating ",
                "Date_Time": "2017-06-12T00:00:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1074,
                "Site": "MMM",
                "Department": "KKK",
                "Side_Roller_Number": "2276",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-27T08:55:00.000+02:00",
                "Login_Name": "Nachshon@tama.co.il",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1073,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2221",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1072,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2244",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "Login_Name": "Nachshon@tama.co.il",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1071,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2077",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1070,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2095",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1069,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2035",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1068,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2017",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1067,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2274",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-22T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1066,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2236",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-18T08:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1065,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2167",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-18T08:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1064,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2272",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-18T08:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1063,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2306",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-18T08:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1062,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2289",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-18T08:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1061,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2036",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-18T08:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1060,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2184",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-12T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1059,
                "Site": "AAA",
                "Department": "KKK",
                "Side_Roller_Number": "2286",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-12T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1058,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2190",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-12T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1057,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2209",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-12T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1056,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2249",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-12T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            },
            {
                "Row_id": 1055,
                "Site": "GGG",
                "Department": "KKK",
                "Side_Roller_Number": "2153",
                "Length": 650,
                "Diameter": "95",
                "Action": "Grinding",
                "Date_Time": "2019-08-12T14:18:00.000+02:00",
                "totalCount": 1066,
                "totalPages": 43,
                "hasMore": "true"
            }
        ]

      • Guy Lior

        In my endpoint the offset is page offset and not records offset, this is why I did modification in the trsnaforms, so in my case as offset you should use 0,1,2, until 42 ( I have 43 pages of 25 records)

      • Guy Lior
      • Michael Blout

        thanks! could you also paste the actual ServiceDataProvider declaration, from the page JSON?

    • John Ceccarelli

      to be clear, go to the page, click the { } and search for the SDP name and copy/paste the full JSON of that SDP definition here.

      • Guy Lior

        Full page JSON:

         

        {
          "pageModelVersion": "19.1.3",
          "title": "",
          "description": "",
          "variables": {
            "Machon": {
              "type": "vb/ServiceDataProvider",
              "defaultValue": {
                "endpoint": "machonPagination/getMachonGetAll",
                "responseType": "getMachonGetAll",
                "idAttribute": "Row_id"
              },
              "required": false,
              "input": "none"
            }
          },
          "types": {
            "@decorators.getMachonGetAll": {
              "endpoint": "getMachonGetAll",
              "service": "machonPagination",
              "path": "response"
            },
            "getMachonGetAll": [
              {
                "Row_id": "number",
                "Site": "string",
                "Department": "string",
                "Side_Roller_Number": "string",
                "Length": "number",
                "Diameter": "string",
                "Action": "string",
                "Date_Time": "string",
                "totalCount": "number",
                "totalPages": "number",
                "hasMore": "string"
              }
            ]
          },
          "chains": {
            "ListViewScrollPositionChangeChain": {
              "description": "",
              "variables": {
                "scrollPosition": {
                  "required": true,
                  "type": "any",
                  "input": "fromCaller"
                }
              },
              "root": "callModuleFunction1",
              "actions": {
                "callModuleFunction1": {
                  "module": "vb/action/builtin/callModuleFunctionAction",
                  "parameters": {
                    "module": "{{$page.functions}}",
                    "functionName": "debug",
                    "params": [
                      "{{ $chain.variables.scrollPosition }}"
                    ]
                  },
                  "outcomes": {
                    "success": "if1"
                  }
                },
                "if1": {
                  "module": "vb/action/builtin/ifAction",
                  "parameters": {
                    "condition": "{{ $chain.results.callModuleFunction1 == 50}}"
                  }
                }
              }
            }
          },
          "eventListeners": {
          },
          "imports": {
            "components": {
              "oj-ext-mobile-page-template": {
                "path": "vb/components/mobile-page-template/loader"
              },
              "oj-list-view": {
                "path": "ojs/ojlistview"
              },
              "oj-vb-list-item": {
                "path": "vb/components/list-item/loader"
              }
            }
          }
        }

        • Guy Lior

          SDP definition

          • Michael Blout

            As a possible workaround (not sure this will work) could you map limit & offset on the SDP to some/any (reasonable) defaults?

            There were changes to be less tolerant of missing endpoint parameters in some areas, and this may be causing an issue in this case.

    • Michael Blout

      any errors now, in the console?
      What service and endpoint is this?  How was it defined? are "limit" and "offset" set as required in the service?

    • Guy Lior

      Hi,

      Service and endpoint defined in OIC connected to SQL server.

       "limit" and "offset" are required.

      When limit and offset are not set at all I see not wors in the list and I am getting the following error in the console:

      [VB (ERROR), /oj]: Error: getConfig() for "getMachonGetAll" is missing required parameters: "offset", "limit"

      If I set default limit to 25 and default offset to 0, I get the first page but it fail in the next try to call the endpoint because the offset parameter appears twice in the constructed url.

      When I define default value to the limit and offset in the SDP level the tesnforms script gets the configuration url already including the limit and offset parameter so when I use the URI(newUrl).addSearch it add another offset value to the URL which is wrong.

      When the limit and offset are not defined with default value at the SDP the transform does not fires at all.

       

       

      • David Konecny

        Just to help you create some short term workaround, could you please try to change your Request paginate function to remove limit/offset? Eg.:

        newUrl = URI(newUrl).removeSearch("limit").removeSearch("offset").addSearch({limit: options.size, offset: (options.offset / options.size )}).toString();
        

        Thanks,
        -David

        • Guy Lior

          Hi David,

          Already tried this. The behavior is not as expected, all pages are loaded when the page load (I see all endpoint calls in the console log, each time with incremented offset) instead of only when scrolling, in addition there are some error in the console (attached)

          Thanks

          Guy 

          • David Konecny

            What UI control are you using to display the content? For example oj-table in its default configuration keeps expanding vertically until if fetches all the rows available. Whenever I use oj-table I always set table's height to be fixed (eg style="height: 600px") and also check that loadMoreOnScroll is set. That should do the trick.

            The error seems unrelated tbh. Or is a seperate issue which should not influence pagination.

            -David

    • John Ceccarelli

      And just to check - you added the OIC integration endpoint using the catalog, not using the define by endpoint?

      • Guy Lior

        Hi,

        Endpoint added using the define by endpoint option.

        • Michael Blout

          So

          - you manually defined the endpoint, and you specified that that the "offset" and "limit" parameters were required?

          - you were able to get past the initial "Endpoint" error, but you are now having an issue where all the pages are fetched?

          - have you been able to try David's suggestion of using a fixed height, and setting "loadMoreOnScroll"?

          - you now see that 'preventDefault' error now (which i agree with David, seems unrelated) after the upgrade?

           

          • Guy Lior

            Hi

            - you manually defined the endpoint, and you specified that that the "offset" and "limit" parameters were required? - YES

            - you were able to get past the initial "Endpoint" error, but you are now having an issue where all the pages are fetched? - YES, also tried to create new app and it is the same

            - have you been able to try David's suggestion of using a fixed height, and setting "loadMoreOnScroll"? - loadMoreOnScroll is set, I am using list and not table

            - you now see that 'preventDefault' error now (which i agree with David, seems unrelated) after the upgrade? - YES, also in my new demo app

            • John Ceccarelli

              So make sure that you've set either an explicit height on the list (or its containing div) or that you've set the scroll-policy-options.scroller property to [[document.documentElement]] to have the list take up the full height of the document but not load more until user actually scrolls to bottom of the document.

              • Guy Lior

                Hi

                scroll-policy-options.scroller property already set to [[document.documentElement]]  and pagination still not working, I see in the console that all pages are fetched with some errors like 'preventDefault'.

                as I wrote before, it worked perfectly in the previous version.

                • John Ceccarelli

                  OK I'd say at this point file an SR and attach your project to the SR. We will review it and get back to you through SR. Very weird, we haven't seen anything like this in house.

    • Ziv Rubin

      Hi Guy,

      As Shay Shmeltzer suggested before, a good temporary workaround while waiting for the SR solution (which I saw you already filed) for issues following the last VBCS upgrade, is setting a permanent JET version:

      https://docs.oracle.com/en/cloud/paas/app-builder-cloud/visual-builder-developer/customize-jet-and-runtime-settings.html

      The format should be as follows:
      Runtime Version: 19.1.3.11
      JET runtime version: v6.1.2

      I hope it can help you in the meantime.

      Regards,
      Ziv

      • Guy Lior

        Hi Ziv,

        Using the versions you suggested make it working again. Thanks

        I still get the error message mentioned above but pagination now works.

        I will wait for updates on the SR.

        Guy