In Aikau. How to get the search query parameters inside a custom widget in a dialog? In Aikau. How to get the search query parameters inside a custom widget in a dialog? json json

In Aikau. How to get the search query parameters inside a custom widget in a dialog?


OK, now that you've added the model I think I might be able to provide a better answer...

It looks like you've just copied the example from the JSDoc. Where you've set the hashDataMapping configuration you can actually reconfigure this to get the search term.

Each time you search, the search text is set on the URL as the searchTerm hash parameter. This means that with useHash configured to be true you can configure the AlfDynamicPayloadButton like this:

{  name: "alfresco/buttons/AlfDynamicPayloadButton",  config : {    label : "My Button",    useHash : true,    hashDataMapping : {      searchTerm: "widgetsContent.0.config.searchTerm"    },    publishPayloadSubscriptions: [],    publishTopic: "ALF_CREATE_DIALOG_REQUEST",    publishPayload: {      dialogTitle: "My Title",      widgetsContent: [        {          name: "myPackage/Example",          config: {            width : 400,            height : 500            // other configurations          }        }      ]    }  }};

The key thing here is that you are mapping the searchTerm URL hash value to the widgetsContent.0.config.searchTerm property of your publishPayload. This means that your custom widget within your dialog will be assigned the last search term that was used (to an attribute also called searchTerm that your widget can reference).


I think you're on the right path with subscribing to the ALF_SEARCH_REQUEST topic. If you're finding that the initial ALF_SEARCH_REQUEST topic (on loading the page) is being published before your AlfDynamicPayloadButton has registered its subscription then you might want to consider upgrading to a more recent Aikau release.

We fixed an issue in the 1.0.68 release to ensure that no publications are fired until all widgets have completed loading on the page (this was actually to address the scenario where there are multiple Surf components on the page which shouldn't be the case on the faceted search page!). We work around this problem by having a shared singleton PubQueue that doesn't release any publications until after all widgets and services have been created.

I suppose this could depends where you're creating your AlfDynamicPayloadButton - for example, if it's in the search results then it will be created after the ALF_SEARCH_REQUEST topic has been published.

Have you checked the DebugLog to ensure that the subscription in your button is being setup correctly (for example that there are no scoping issues?).

Have you verified that a fixed payload (with hard-coded data) will result in the displaying the dialog as you require? Have you verified that the button is not successfully subscribing to the topic but just not building the payload as required.

Could you also update your question to show the configuration for your AlfDynamicPayloadButton as this might help me figure out what the problem is.