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:
Service Configuration:
Pagination Logic:
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});
I would appreciate any guidance or suggestions on how to resolve this issue. Thank you!
Solved! Go to Solution.
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.
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.
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
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
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