cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Issue with Pagination Widget in ThingWorx mashup with QueryImplementingThingsOptimizedWithTotalCount

Bhavya_PC
4-Participant

Issue with Pagination Widget in ThingWorx mashup with QueryImplementingThingsOptimizedWithTotalCount

Hello All,

I am currently facing an issue with the pagination widget in my ThingWorx mashup. The initial load of the data works perfectly, but when I select a page number from the pagination widget, the service fails to return the correct data and gives an error code 500(Error executing service Test1.Message: : Wrapped java.lang.NullPointerException-See Script Error Log for more details.). Specifically, the last page fails when it has fewer rows than the page size.

Here is a summary of my setup:

  1. Service Configuration:

    • I am using the QueryImplementingThingsOptimizedWithTotalCount service to fetch data with pagination.
    • The service parameters include maxItems, offset, and query.
  2. Pagination Logic:

    • The offset is calculated as (pageNumber - 1) * pageSize.
    • The service correctly handles the initial load but fails when navigating to the last page with fewer rows.
  3. Code Snippet:

    var offset_Value = (pageNumber - 1) * pageSize;
    
    let assetList = ThingTemplates["BasePlatform"].QueryImplementingThingsOptimizedWithTotalCount({
        maxItems: pageSize,
        offset: offset_Value,
        propertyNames: propertylist,
        query: query
    });

    var numRows = totalAssets; var startRow = Math.max(0, (pageNumber - 1) * pageSize); var endRow = Math.min(startRow + pageSize, localInfoTable.length); for (var r = startRow; r < endRow; r++) { paginatedResult.addRow(assetList.getRow(r)); } result.AddRow({numberOfRows: numRows, assetData: paginatedResult}); 
  4.  Problem:
    • The service works fine on the initial load but fails with error code 500 when navigating to the next page using the pagination widget.
    • The last page fails when it has fewer rows than the page size.

    I would appreciate any guidance or suggestions on how to resolve this issue. Thank you!

 

ACCEPTED SOLUTION

Accepted Solutions

Put in loggings to find out which call causes the NullPointerException. Then find out if you give the service call valid parameters.

If so, that suggests a product issue and you need a ticket with support.

 

Otherwise, are you really adding the rows to the result? The service is called AddRow, not addRow.

View solution in original post

4 REPLIES 4

Put in loggings to find out which call causes the NullPointerException. Then find out if you give the service call valid parameters.

If so, that suggests a product issue and you need a ticket with support.

 

Otherwise, are you really adding the rows to the result? The service is called AddRow, not addRow.

slangley
23-Emerald III
(To:Bhavya_PC)

Hi @Bhavya_PC 

 

If the response to your post was helpful, please mark it as the Accepted Solution for the benefit of others in the Community.

 

Regards.

 

--Sharon 

PEHOWE
17-Peridot
(To:Bhavya_PC)

Hello @Bhavya_PC ,

I always like an example which works. So I did a little search in the Knowledge base and found Article - CS360936 - How to prepare data source for ThingWorx Pagination widget
This article contains a link Sample entity to a zip file This file contains 3 XML files which you can import and then you will have a working example of pagination.

Let me know if this helps

Regards,

Pehowe

 

PEHOWE
17-Peridot
(To:Bhavya_PC)

Hello @Bhavya_PC ,

It appears that your question, has been provided next steps and possibly a solution.  For the benefit of other Community Members who may have the same question, it would be great if you could designate it as the Accepted Solution.

In the event that this response did not answer your question, please post your current status so that we can continue to support.

Thanks for using the PTC Community!

Regards,

pehowe

Announcements


Top Tags