cancel
Showing results for 
Search instead for 
Did you mean: 

Extending the Aikau Search page (faceted-search)

voula_11
Champ in-the-making
Champ in-the-making
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
4 REPLIES 4

ddraper
World-Class Innovator
World-Class Innovator

Sorry for the slow response on this, but I've only just seen this question on the forums…

Firstly, it's worth pointing out that we wrote the search page very much with infinite scrolling in mind, however that said ideally we'd want to be able to support the use of standard pagination as well. I've taken a look through the code and it looks like we're missing a few things to get this to work properly.

Part of the issue is that the "alfresco/search/AlfSearchList" (this is in the latest versions of Aikau, the old "alfresco/documentlibrary/AlfSearchList" is now deprecated) overrides quite a few parts of the standard list behaviour. Some of these can be worked around through configuration… for example if you were to configure your "alfresco/lists/Paginator" like this:


{
   name: "alfresco/lists/Paginator",
   config: {
      documentsLoadedTopic: "ALF_RETRIEVE_DOCUMENTS_REQUEST_SUCCESS",
      totalResultsProperty: "response.numberFound",
      startIndexProperty: "response.startIndex"
   }
}
‍‍‍‍‍‍‍‍‍‍



You'd find that it is then able to process the results and work out the number of pages available, etc. Unfortunately one part of this is missing which is the ability to actually drive page selection. This is caused by the AlfSearchList not making a call to the "setupSubscriptions" or "updateLoadDataPayload" functions defined in the "alfresco/lists/AlfSortablePaginatedList" widget that it extends. This would have provided the capabilities to make the AlfSearchList work with the Paginator.

I've raised an issue in JIRA for us to address this problem https://issues.alfresco.com/jira/browse/AKU-414

We'll include this in a future sprint and you'll then be able to use a future version of Aikau with 5.0.d (see https://community.alfresco.com/community/ecm/blog/2015/03/24/why-alfresco-50d-will-be-a-game-changer...) to resolve your problems.

Regards,
Dave

voula_11
Champ in-the-making
Champ in-the-making
Hi Dave,

Thank you very much for your response. This helps a lot. We will keep the search results page as an infinite list until this is fixed in Aikau.

Cheers,
Voula

ddraper
World-Class Innovator
World-Class Innovator
As of Aikau 1.0.30 you can now customize the faceted search page to be both paginated and to not use browser URL hashing

birundha
Champ in-the-making
Champ in-the-making

I need to add pagination in the faceted search page of Alfresco 5.2 version with Aikau 1.0.101.3 . How can I do this? Can you please provide me a sample