AnsweredAssumed Answered

Extending the Aikau Search page (faceted-search)

Question asked by voula_11 on Jun 18, 2015
Latest reply on Mar 12, 2018 by birundha
Hello,

I am customizing Alfresco Share and one of my tasks is to make the Search Results paginated instead of an infinite scroll. I am on Community 5.0.d with Aikau version 1.0.8.1.

So far, I've downloaded the faceted-search JAR from the Developer View in the faceted search page and have the following code:

<javascript>
// get the search results list
var searchResultsList = widgetUtils.findObject(model.jsonModel.widgets, "id", "FCTSRCH_SEARCH_RESULTS_LIST");
if (searchResultsList){
   // disable infinite scroll
   searchResultsList.config.useInfiniteScroll = false;
   // remove the Gallery View and the infinite scroll View
   searchResultsList.config.widgets.splice(1,2);
}

// create the paginator menu bar
var pagination = {
   name: "alfresco/documentlibrary/AlfDocumentListPaginator",
   align: "right"
};
// get the existing menu bar
var menuBar = widgetUtils.findObject(model.jsonModel.widgets, "id", "FCTSRCH_RESULTS_MENU_BAR");
if (menuBar) {
   // remove the View Selection widget (we only want one paginated view)
   menuBar.config.widgets[2].config.widgets.splice(2,1);
   // add the paginator widget
   menuBar.config.widgets.push(pagination);  
}
</javascript>

The widget shows up, and only the first 25 results are shown. However, I get the following error (and thus cannot navigate between pages):


alfresco/core/CoreWidgetProcessing[createWidget] >> The following error occurred creating a widget TypeError: Cannot read property 'totalDocuments' of undefined
    at alfresco_documentlibrary_AlfDocumentListPaginator__processLoadedDocuments [as processLoadedDocuments] (https://alfresco.dev.urthecast.com/share/res/js/surf/1c2eeba992cc846899ed28fbc174967c.js:74809:21)
    at alfresco_documentlibrary_AlfDocumentListPaginator__allWidgetsProcessed [as allWidgetsProcessed] (https://alfresco.dev.urthecast.com/share/res/js/surf/1c2eeba992cc846899ed28fbc174967c.js:75100:18)
    at alfresco_core_CoreWidgetProcessing___registerProcessedWidget [as _registerProcessedWidget] (https://alfresco.dev.urthecast.com/share/res/js/surf/1c2eeba992cc846899ed28fbc174967c.js:13748:18)
    at https://alfresco.dev.urthecast.com/share/res/js/surf/1c2eeba992cc846899ed28fbc174967c.js:14100:28
    at runFactory (https://alfresco.dev.urthecast.com/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:1117:43)
    at execModule (https://alfresco.dev.urthecast.com/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:1245:5)
    at https://alfresco.dev.urthecast.com/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:812:7
    at guardCheckComplete (https://alfresco.dev.urthecast.com/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:1260:5)
    at contextRequire (https://alfresco.dev.urthecast.com/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:811:6)
    at req (https://alfresco.dev.urthecast.com/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:137:11)
Object {_attachPoints: Array[1], _attachEvents: Array[0], _connects: Array[0], _supportingWidgets: Array[0], id: "alfresco_documentlibrary_AlfDocumentListPaginator___fc29981b-ab52-48d0-8e9b-f31e57bc9c46"…}


The line where the error occurs:
<javascript>
processLoadedDocuments: function alfresco_documentlibrary_AlfDocumentListPaginator__processLoadedDocuments(payload) {
         if (payload.totalDocuments !== null && payload.startIndex !== null)
</javascript>


I've been stuck on this for days, and I can't figure out why the payload being passed to this function is undefined.

Is it because the FCTSRCH_SEARCH_RESULTS_LIST has to publish a topic that the Paginator has to subscribe to in order to get all the necessary information for the widget? How do I do this?

Any help would be appreciated.

Thanks,

Voula

Outcomes