Implementing a navigation hook
Smart Navigator provides a hook where customized business logic can be added between the click of a result and navigation to the related page.
About this task
Smart Navigator enables a user to directly navigate from a search result to the intended page without requiring the user to traverse intermediate pages. However, there might be scenarios where the direct navigation from a search result to a page is not the intended behavior and therefore the direct navigation needs to be intercepted. The proceeding JavaScript hook addresses the problem by providing a mechanism to insert custom logic between when the user clicks the result and when the user navigates to the related page. For example, a custom implementation might open a modal when the user clicks a result to display information that might be considered important but would otherwise be bypassed. To provide an implementation of the hook, apply the proceeding steps.
Procedure
webclient/components/custom/WebContent/CDEJ/jscript/curam/widget
. Where it is
indicated, use custom implementation.
/**
* @name curam.widget.SearchMultipleTextBoxHookPoints
*
* API for implementing hook points exposed by SearchMultipleTextBox (Smart Navigator).
*
*/
define([
"dojo/topic"], function(topic) {
curam.define.singleton("curam.widget.SearchMultipleTextBoxHookPoints", {
/**
* Implement this function in order to add custom processing between
* click of a Smart Navigator result and the rendering of the page.
*
* This hook cannot alter navigation, Smart Navigator is responsible
* for completing navigation, that is, saving to history and rendering
* the URL.
*
* If this hook is used to interact with the user then a modal approach
* should be used to prevent page navigation given when this hook
* completes the URL will be rendered by Smart Navigator.
*
* @param data Object holding:
* url being navigated to
* concernRoleId: concernRoleID of individual if result is a person or keyword of a person.
*
* @return publish message '/smartnavigator/prenavigationhook/completed' to hand back control.
*/
preNavigationHook: function(data){
// Custom implementation goes here
// On completion, publish message to hand control back to smart navigator.
topic.publish('/smartnavigator/prenavigationhook/completed');
}
});
return curam.widget.SearchMultipleTextBoxHookPoints;
});
The final step in the hook implementation must be to assign control back to Smart Navigator so that navigation can be completed.
topic.publish('/smartnavigator/prenavigationhook/completed');