Show TOC

Accessing the "search" ContractLocate this document in the navigation structure

This contract interface allows the page builder to get the CHIP-specific search keywords. In addition, it can have the CHIP highlight words in its UI based on the search terms used.

As a prerequisite, you have to consume the search contract in the CHIP definition XML.

The search property is then available in the CHIP API. It provides the following methods:

  • chip.search.setKeywords()

    You can use this method to set CHIP-specific keywords for finding the CHIP in an overall CHIP search. If the CHIP does not set any keywords, the page builder can only search based on CHIP metadata like the CHIP title.

  • chip.search.attachHighlight()

    You can use this method to attach an event handler to the "highlight" event, which is fired whenever the user executes a search over all CHIPs using specific search terms. The words to be highlighted, which are provided as parameters to the event handler, are derived from the search terms. The CHIP can highlight these in its UI.

Example:

Code Example
onInit: function() {
  varoChipApi = this.getView().getViewData().chip,
    oResourceBundle = this.getView().getModel("i18n");

  oChipApi.search.setKeywords([oResourceBundle.getProperty("info"], oResourceBundle.getProperty("subtitle"]);
  oChipApi.search.attachHighlight(function(aHighlightWords) {
    //enable CHIP UI to highlight words
  });
}

In this example, the CHIP instance sets its language-dependent, CHIP-specific search keywords in its onInit method. In addition, it attaches an event handler for highlighting words from the search in its UI.