I have a news page with hundreds of news items so we are applying pagination on this page and displaying 20 items per page – For this we applying the filter in broker query as below -
query.setResultFilter(new PagingFilter(minitems,pageSize));
Now after executing below query we are getting the news components URIs -
String [] comURIs = query.executeQuery();
Now in these components there are few components which do not have any component presentation with the component template used on this concerned page. In other words below code gives some NULL component presentations (cp). -
for (int i =0; i < comURIs.length; i++)
{
ComponentPresentation cp = cpf.getComponentPresentation(comURIs[i], strCTuri);
}
Now below is the issue due to these NULL component presentations -
"When API code executes for the pagination index 1, there are some NULL CP (suppose 5 out of total 20) available and we are excluding these NULL CPs from the returned result set. As a result this page with pagination index 1 display only 15 items and page with pagination index 2 and onward displaying all 20 items”
I need consistency in item per page and also “item per page” is getting set by the Editors. How to deal with this issue, please suggest.