cancel
Showing results for 
Search instead for 
Did you mean: 

Aikau AlfSearchResult bad behavior

nilsonmorais
Champ in-the-making
Champ in-the-making

Hi,

I'm having some problem extending AlfSearchResult, when using the native widget it works well, but when I try extending it still shows the results, but only when I trigger the search event for the second time (Two clicks on search button for example), instead it shows Search Suggestions.

I did the same thing extending other widgets and only this one shows this behavior.

Thanks in advance for any help. Smiley Happy

Original code:

{

  "name": "alfresco\/search\/AlfSearchResult",

  "config": {

  "enableContextMenu": false

  },

}

Using custom widget:

{

  "name": "js\/AlfSearchResult",

  "config": {

  "enableContextMenu": false

  },

}

Custom Widget (AlfSearchResult.js):

define([

  "dojo/_base/declare",

  "dijit/_WidgetBase",

  "alfresco/core/Core",

  "alfresco/search/AlfSearchResult",

    "alfresco/lists/views/layouts/Row",

    "alfresco/search/SearchThumbnail",

    "alfresco/renderers/PropertyLink",

    "alfresco/renderers/Property",

    "alfresco/renderers/DateLink",

    "alfresco/renderers/XhrActions",

    "dojo/_base/lang",

    "dojo/dom-class",

    "alfresco/renderers/XhrContextActions",

    "alfresco/renderers/Selector",

    "alfresco/renderers/Size",

    "alfresco/renderers/MoreInfo",

    "alfresco/enums/urlTypes",

  ],

  function(declare, _WidgetBase, Core, AlfSearchResult, Row,SearchThumbnail, PropertyLink,

  Property, DateLink, XhrActions, lang, domClass, XhrContextActions, Selector, Size, MoreInfo, urlTypes,

  ) {

  return declare([AlfSearchResult], {

  postCreate: function custom_AlfSearchResult__postCreate() {

  this.inherited(arguments);

  },

  });

});

4 REPLIES 4

ddraper
World-Class Innovator
World-Class Innovator

First of all ... What versions of Alfresco and Aikau are you using?

So essentially you're just creating a custom version of the AlfSearchResult widget that is (in theory) exactly the same as the original? (or have you omitted some of your code?)

One thing I would say is that you should definitely define your custom models in a specific package (rather than just "js") as I've seen this cause problems before - I can't remember where or why - just that I'm fairly sure it's caused problems in the past!

Are you getting any errors in the browser console? (make sure you're running in client debug mode - and have enabled logs)

Other things to suggest when debugging would be to set the browser developer tools to break on exceptions and see if something is breaking somewhere.

nilsonmorais
Champ in-the-making
Champ in-the-making

First of all ... What versions of Alfresco and Aikau are you using?

My bad, there it goes... Aikau 1.0.83 Alfresco 5.1.0

So essentially you're just creating a custom version of the AlfSearchResult widget that is (in theory) exactly the same as the original? (or have you omitted some of your code?)

That's it, exactly the same (at least for now).

One thing I would say is that you should definitely define your custom models in a specific package (rather than just "js") as I've seen this cause problems before - I can't remember where or why - just that I'm fairly sure it's caused problems in the past!

ok, done.

Are you getting any errors in the browser console? (make sure you're running in client debug mode - and have enabled logs)

Other things to suggest when debugging would be to set the browser developer tools to break on exceptions and see if something is breaking somewhere.

Logs are enabled, no errors.

I added this.alfLog("log","I'm Here") and it's calling from inside my scope.

The custom widget it's working fine, I got a call for each result, it renders and returns...

I just need to click two times to send the search to it, which is not the same behavior as the native one.

Thanks for the tips! Smiley Happy

ddraper
World-Class Innovator
World-Class Innovator

I'm still totally confused as to why two clicks would be required - let me know if you find the answer!

nilsonmorais
Champ in-the-making
Champ in-the-making

Hi Dave,

I Kinda found the problem. Looking the logs, at some point alfresco_lists_views_layout___MultiItemRendererMixin__renderData is called and do a renderNextItem for each item in search results. Then it calls MultiItemRendererMixin->renderNextItem, which calls this.processWidgets(clonedWidgets, this.containerNode), here the cloned widget is a instance of my custom AlfSearchResult, which should be rendered in containerNode.

Then when I click on the "search button" on my page and I stop at the line this.processWidgets(clonedWidgets, this.containerNode), the DOM element (this.containerNode) already exists and so AlfSearchResult renders correctly.

But when I stop at the same line when the page loads, this.containerNode targets the same DOM element from before, but this time the DOM element doesn't exists in document yet. That's why it can't render the results when the page loads.

The DOM element in question is a div element from the parent widget (AlfSearchList) but from some reason isn't rendered yet. I'm still trying to figure out how to solve this.

Regards.